Conversation
When we are using `size-limit` with` @size-limit/webpack-css` plugin `v10.0.1` we are having an issue and see this error running `size-limit` during plugin loading ``` ReferenceError: require is not defined in ES module scope, you can use import instead This file is being treated as an ES module because it has a '.js' file extension and 'src/experiment /size-limit-experiment/node_modules/@size-limit/webpack-css/package.json' contains \"type\": \"module\". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.\n ``` As a solution we use createRequire to require commonjs from esm module. --- Also, - adding webpack-css plugin as a workspace to global workspace package.json. - checking that load-plugins() is not throwing an error when we load webpack-css (https://github.com/mendrew/size-limit/blob/f9e9a78c3f62be7061bfd25efa7e546f02de549c/packages/size-limit/test/load-plugins.test.js#L8-L16)
Owner
|
Thanks. I will try to release it today. |
Owner
|
Released in 10.0.2 |
Contributor
Author
|
Great, thank you very much Andrey! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Good day! Thank you very much for this amazing tool!
Problem
In our project we are using
size-limitwith@size-limit/webpack-cssplugin and with latest versionv10.0.1we are having an issue and see this error runningsize-limit.The whole error
Version
size-limit: v10.0.1
node: v18.8.0.
To reproduce
Here is a repo example with reproduction: https://github.com/mendrew/stunning-journey
Proposal
As a solution we use
createRequireto require commonjs from esm module like we do here insize-limitin other modules. Works well in my case. Hope it close to a solution.Changes
Notes
Unfortunately I was not able to reproduce this issue in tests. Any ideas where I can put a test which would be similar to the example with reproduction?
load-plugins.test.jsdoesn't catch this issue.