-
Notifications
You must be signed in to change notification settings - Fork 609
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
3.0.8 no longer compatible with react-scripts 1.1.4 #1480
Comments
|
I believe the issue is with mixing both If I understand correctly you only need on or the other, not both. In this case, canvg's Here's the message node prints when importing
|
does the prior version work where i may have done something wrong w/ the deploy or was it code/deps from the diff that fails to minify? @dangreen any help here would be appreciated - i just ran |
Here's an example of trying to import in both ESM and CJS input-modes (node v16.6.2): CJS:$ node --input-type=commonjs --eval "require('canvg')" node:internal/modules/cjs/loader:1150 throw err; ^ Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/canvg/lib/index.js from [eval] not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in node_modules/canvg/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). ESM:$ node --input-type=module --eval "import 'canvg'" file://node_modules/canvg/lib/index.es.js:18 import { SVGPathData } from 'svg-pathdata'; ^^^^^^^^^^^ SyntaxError: Named export 'SVGPathData' not found. The requested module 'svg-pathdata' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: |
@gabelerner I'll look at the weekend |
If I understand correctly it is using webpack 3.8.1, uglifyjs-webpack-plugin 0.4.6 and uglify-js 2.8.29 and also babel-core 6.26.0 which may have nothing to do with it. |
@jakber can you try canvg@3.0.9 ? |
@dangreen I get the same problem with 3.0.9. It seems like ./node_modules/canvg/lib/index.es.js uses a lot of modern features like object destructuring with renaming, functions in object literals and generators. I could fix a few lines by e.g. changing line 29 to 3.0.7 looks completely different. Not sure why. I noticed that target is "esnext" in tsconfig.json but "es5" in tsconfig.dev.json (and that has not changed recently). But if your build/publish process changed to use tsconfig.json instead of tsconfig.dev.json maybe that could have something to do with it? |
|
Current react-scripts version is 4.0.3 (3 versions higher).
all of these has few major updates, uglifyjs-webpack-plugin 2 years without updates so I think your setup just can't parse modern js. |
That's exactly right, it can't (https://create-react-app.dev/docs/troubleshooting/#npm-run-build-fails-to-minify). Probably not worth fixing, but maybe 3.0.8 should be 4.0.0 if it drops support for old runtimes? If not that's cool too, just wanted to let you (and others with the same problem) know that something changed in case you weren't aware. |
@jakber If you are able to customize webpack config, you can try to let babel-loader transpile canvg, or set mainFields without |
Hi,
I know I should upgrade my react-scripts, but just FYI (and for anyone searching for this error message) 3.0.8 caused my build to fail with:
3.0.7 worked fine yesterday. Pinning the version by adding
"canvg": "3.0.7"
to package.json makes it build again.The text was updated successfully, but these errors were encountered: