-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
bytesInOutput from metafile is incorrect for css files since v0.12.12 #2071
Comments
After some more investigation it seems like the bytesInOutput is incorrect even when not supplying a publicPath. It is incorrect whenever the css files include a The If you change the .svg loader to be |
But |
Well, "dist/index.css": {
"imports": [],
"inputs": {
"style.css": {
"bytesInOutput": 201
}
},
"bytes": 177 It does seem like a bug. Did not happen on I need the correct bytes to be able to after the bundling re traverse the tree and create a merged css file containing chunks in correct order from multiple entrypoints (server and clients), in the imba bundler. Our custom logic worked perfectly for this when we used If this is sort of working as intended, I can see us bypassing the Btw esbuild is the most impressive open-source project I've had the pleasure to use in many years. I cannot thank you enough for how fantastic it has been for us and how well it works in the imba bundler. |
About to start undertaking the hack where we inject legal comments in all css inputs to get around this, so would love to hear if you think this will be resolved at some point or if I should rather explore workarounds :) If it was possible to explicitly turn off minification just for the css I could also use the header comments above each input to extract the chunks, but afaik there is no option to do this. @evanw: would it be helpful if I figured out the exact version where it started breaking? |
Improved the testcase in the mentioned repo and found out that the bug was introduced in v0.12.12. Again, this happens without any configuration at all. |
I have created a PR that solves the issue. Issue statement
@evanw I'd love to have a review on the PR if possible. It's quite small and has a couple of tests. |
UPDATE:
bytesInOutput
is actually incorrect whether you supply apublicPath
or not. As long as you have aurl(...)
somewhere in your css that imports a path using file-loader.When you supply a
publicPath
, the bytesInOutput value is incorrect for css files. Repository with minimal reproducible example can be found here: https://github.com/somebee/esbuild-bytes-offset-bug.Take the input:
When specifying a publicPath
/some-long-public-path/
, esbuild generates the following:And metafile:
bytesInOutput
of styles.css is shorter than the real output, as it does not include the/some-long-public-path
in the calculation. The real bytesInOutput is 76The text was updated successfully, but these errors were encountered: