-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Modules namedExport with backward compatibility #1184
Comments
Unfortunately this is not possible, export const foo = 'abc'
export const bar = 'def'
export default {foo: 'abc', bar: 'def'} Bad idea, named export was created for concatenations modules, using this code will destroy all benefits. Workaround - you can use |
|
I understand this, why we shouldn't mix this is described below
And yes and no, depends on how the code is written, but only named always works with tree shaking |
I can't fully understand, why mixed exports is bad) Have module:
Use it at old code:
Use it at new code:
Both variants should working well, and allow unused code removing |
When you bundle libraries we don't know what should be tree shaking, so using locals in |
Agreed with that, thanks you! |
Hello!
Had a try to adopt a new feature with named exports to existing project, and have a problem with third-party libraries.
Use case
For example, we have application, with ui-kit library, which export components with css modules, and custom css modules.
Inside ui-kit, components use default exports from css modules (and we can't change this behaviour):
Our components want to use named exports:
With current
css-loader
named exports implementation, we will have a error:"export 'default' (imported as 'styles') was not found in '@some-ui-kit/button.module.css'
Implementation
From this css:
with special option, generate named and default exports at the same time:
This behaviour doesn't break tree shaking.
If this idea don't have any drawbacks, i can try implement it in css-loader and mini-css-extract-plugin
The text was updated successfully, but these errors were encountered: