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

[css-minifier] Support layer for @import #3137

Closed
binyamin opened this issue May 28, 2023 · 1 comment
Closed

[css-minifier] Support layer for @import #3137

binyamin opened this issue May 28, 2023 · 1 comment

Comments

@binyamin
Copy link

CSS allows authors to assign a cascade layer to an imported file, like so:

@import 'theme.css' layer(core);

This is equivalent to having enclosed the contents of the imported file in a cascade layer.

Expected Behavior: Output the import statement with the layer-name. The only relevant optimization I can think of is minification.
Actual Behavior: Esbuild thinks it's a conditional import, and throws an error, because it can't bundle conditional imports.


@evanw
Copy link
Owner

evanw commented Jun 9, 2023

This isn't trivial to implement because currently importing a file twice doesn't actually bundle it twice (i.e. imports are deduplicated by their file path). I think this would mean that different layers should essentially count as different files. Which should be possible to implement, but I'll have to integrate this information into esbuild's internal file cache key.

@evanw evanw closed this as completed in 4bb897f Aug 7, 2023
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

No branches or pull requests

2 participants