Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(tree-shaking): remove dynamic and require dep after tree-shaking #1426

Open
stormslowly opened this issue Jul 18, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@stormslowly
Copy link
Member

stormslowly commented Jul 18, 2024

problem

// ==> index.ts <==
import { foo } from "./foo";

console.log(foo());
// ==> foo/foo.js <==
console.log('foo/foo');
// ==> foo/index.js <==
export function foo() {
  console.log(1);
}

export function bar() {
  return require("./foo.js");
}

after tree-shaking, function bar is removed, but there is still a edge to foo/foo.js, so it will be kept in the module graph.

expect the foo/foo.js removed from the module graph

solution

after tree-shaking , analyze the shaken ast, to found if the dynamic and cjs-require are still in use.

@sorrycc sorrycc added enhancement New feature or request and removed improvement labels Jul 18, 2024
@Jinbao1001 Jinbao1001 self-assigned this Jul 19, 2024
@stormslowly stormslowly assigned goo-yyh and unassigned Jinbao1001 Jul 19, 2024
@stormslowly
Copy link
Member Author

@goo-yyh 增加一个 foo 在环上的 case,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants