-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
esbuild should add "assert" option to css imports #1871
Comments
Although import assertions seem to be a standard way to specify asset types, it may break many other bundlers (mainly webpack) at current time. We should see whether tsc/babel/webpack/rollup are going to adopt this behavior too. |
webpack has examples with asserts on this page: https://webpack.js.org/loaders/css-loader/ |
also it could be deactivatable via option |
rollup also works on this: rollup/rollup#3799 rollup/rollup#4267 |
Import assertions are already supported in esbuild (since version 0.11.22 which was released way back in May 2021). They will be copied over to the output as long as the import path is external and the configured target environment supports parsing import assertions (e.g. with |
@evanw also other syntax features are transformned when using a different target, so why not imports? |
But imports are transformed: if you target an older browser that can't understand |
Closing as "won't fix" for the reason described above. Adding |
But as stated here: #2314 assert with type css does still not work (it does not im my tests). A import with assert type css should return a cssStylesheet object |
Yes. See my comment in the link you posted: #2314 (comment). |
Yes, but that a file is imported more than once with different attributes is a edge case wich mostly will never occure. The feature is in chrome nearly 2 years, the spec is already again at stage 3, so it could be used. |
I'd like to be able to do something like this:
wich does not work yet, but hopefully this is possible (first hour i'm look into esbuild plugins please be patient). |
if a css file is imported, esbuild should fix the output, so it contains assert for css.
see: https://web.dev/css-module-scripts/
The text was updated successfully, but these errors were encountered: