Skip to content

feat: support named exports with any characters #1057

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

laverdet
Copy link

@laverdet laverdet commented Oct 24, 2023

A proposed change to css-loader will allow named exports to be any string, regardless of whether or not it is a valid identifier. The code generation in this project assumes that all exports will be a valid identifier, so the generation stage has been updated to take this into account.

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

When using the new "asIs" named exports feature I submitted in webpack-contrib/css-loader#1549, this module will produce incorrect output since the export names may not be valid local identifiers.

Breaking Changes

Requires support for export { local as "string literal" } syntax which is not supported until nodejs v16.x.

Additional Info

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

A proposed change to `css-loader` will allow named exports to be any
string, regardless of whether or not it is a valid identifier. The code
generation in this project assumes that all exports will be a valid
identifier, so the generation stage has been updated to take this into
account.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 24, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: laverdet / name: Marcel Laverdet (5f09729)

@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
#1057
seek-oss/css-modules-typescript-loader#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.

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

Successfully merging this pull request may close these issues.

1 participant