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

feat: Support named exports #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

laverdet
Copy link

@laverdet laverdet commented Oct 24, 2023

BREAKING CHANGE: Updates the declaration template.

This is a followup on #38

The exports = declaration was added in e7342df but removed in 908d491 due some issue in babel which I can't reproduce. Maybe that has been fixed downstream in the meantime.

Due to microsoft/TypeScript#40594 we cannot export these names directly since class names might not be valid JavaScript identifiers, even though they are valid exported names. When that TypeScript bug is resolved this can be changed to export the names directly instead of using export =. The problem with export = is that it will let you do import * as css from ... in addition to import css from ... even though only import * will work.


When the TypeScript bug is resolved this output should be converted to use named exports instead of exports =

Named exports resolve the Terser bailout condition described in webpack/webpack#17626 but reduce "grepability" of your code.

BREAKING CHANGE: Updates the declaration template.

This is a followup on seek-oss#38

The `exports =` declaration was added in e7342df but removed in
908d491 due some issue in babel which I can't reproduce. Maybe that
has been fixed downstream in the meantime.

Due to microsoft/TypeScript#40594 we cannot export these names directly
since class names might not be valid JavaScript identifiers, even though
they are valid exported names. When that TypeScript bug is resolved this
can be changed to export the names directly instead of using `export =`.
The problem with `export =` is that it will let you do `import * as css
from ...` in addition to `import css from ...` even though only
`import *` will work.
@laverdet
Copy link
Author

This is part of a series of pull requests which adds better ecosystem support for exporting original, non-mangled, CSS names as named exports.

webpack-contrib/css-loader#1549
webpack-contrib/mini-css-extract-plugin#1057
#50

Due to the optimization bailout condition [webpack/webpack#17626] with JSON default exports consumed by hoistable functions, original non-minified CSS module class names can be found in the minified source code.

@laverdet
Copy link
Author

laverdet commented Jun 4, 2024

microsoft/TypeScript#40594 has been fixed and seems like it will land in 5.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant