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

"export *" prevent shaking and removal of unused code #1311

Closed
layershifter opened this issue Aug 1, 2023 · 1 comment
Closed

"export *" prevent shaking and removal of unused code #1311

layershifter opened this issue Aug 1, 2023 · 1 comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@layershifter
Copy link
Contributor

Environment

Description

The fixture in the repro case is based on the real project where a lot of "export *" are used. This confuses current parsing/shaking logic and forces to evaluate more code than needed, in this case:

class MockMediaQueryList extends EventTarget {
  constructor(media, matches = false) {
    super();
    this.media = media;
    this.matches = matches;
  }
}
RROR in ./src/index.js
Module build failed (from ./node_modules/@linaria/webpack-loader/lib/index.js):
EvalError: Class extends value undefined is not a constructor or null in
| /home/projects/stackblitz-starters-aw9m5a/src/lib/hooks/useMedia.js
| /home/projects/stackblitz-starters-aw9m5a/src/lib/hooks/index.js
| /home/projects/stackblitz-starters-aw9m5a/src/lib/dialog.js
| /home/projects/stackblitz-starters-aw9m5a/src/lib/index.js
| /home/projects/stackblitz-starters-aw9m5a/src/index.js

    at Module.evaluate (file:///home/projects/stackblitz-starters-aw9m5a/node_modules/@linaria/babel-preset/lib/module.js:350:13)
    at require.Object.assign.ensure (file:///home/projects/stackblitz-starters-aw9m5a/node_modules/@linaria/babel-preset/lib/module.js:289:13)
    at eval (file:///home/projects/stackblitz-starters-aw9m5a/src/lib/hooks/index.js:6:17)
    at eval (file:///home/projects/stackblitz-starters-aw9m5a/src/lib/hooks/index.js:28:3)

This fixture is good by two reasons:

  • it shows the problem with export *
  • it shows the problem with removing DOM related things where they are used in extends

Reproducible Demo

@layershifter layershifter added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Aug 1, 2023
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Aug 1, 2023
@layershifter
Copy link
Contributor Author

This have been fixed in v5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

1 participant