Skip to content

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

@layershifter

Description

@layershifter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions