Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

swwind/remove-exports

Repository files navigation

@swwind/remove-exports

This module is ESM only, written in Rust and compiles into WASM, supports NodeJS and Browsers.

Remove specific named exports in a JS file, also removes non-used imports and declarations caused by removal.

Used for tree shaking server-specific codes in full-stack js frameworks.

// === before ===

import { database } from "backend";
import { useState } from "frontend";
import "./style.css";

const USER_NAME = "admin";

export const findUser = async () => {
  return await database.findUser(USER_NAME);
};

export function Component() {
  const [count, setCount] = useState(0);
  return <div>{count}</div>;
}

// === after removing "findUser" ===

// import { database } from "backend";
import { useState } from "frontend";
import "./style.css";

// const USER_NAME = "admin";

// export const findUser = async () => {
//   return await database.findUser(USER_NAME);
// };

export function Component() {
  const [count, setCount] = useState(0);
  return <div>{count}</div>;
}

API

import { remove_exports } from "@swwind/remove-exports";

const code = `export var foo, bar;`;
const result = remove_exports(code, ["foo"]);
// => `export var bar;`

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published