@swwind/remove-exports
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@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;`

Readme

Keywords

Package Sidebar

Install

npm i @swwind/remove-exports

Weekly Downloads

9

Version

1.0.0

License

MIT

Unpacked Size

1.37 MB

Total Files

8

Last publish

Collaborators

  • swwind233