flow: Vaadin 14 builds fail with "Cannot find package '@babel/plugin-proposal-object-rest-spread' "
Description of the bug
Any Vaadin 14 project without a package-lock.json will fail a build with the error
ERROR in ../target/frontend/generated-flow-imports.js?babel-target=es6
08:54:23 Module build failed (from ../node_modules/babel-loader/lib/index.js):
08:54:23 Error: Cannot find package '@babel/plugin-proposal-object-rest-spread' imported from /opt/agent/work/311d829d3d5d9e38/integration-tests/babel-virtual-resolve-base.js
08:54:23 at new NodeError (/opt/agent/work/311d829d3d5d9e38/integration-tests/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:203:5)
08:54:23 at packageResolve (/opt/agent/work/311d829d3d5d9e38/integration-tests/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:873:9)
Expected behavior
The build succeeds
Minimal reproducible example
Clone https://github.com/vaadin/skeleton-starter-flow-spring/tree/v14 Delete package-lock.json mvn install -Pproduction
Versions
- Vaadin / Flow version: 14.10.0
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 13
- Comments: 34 (17 by maintainers)
Links to this issue
Commits related to this issue
- fix: removed babel/plugin-proposal-object-rest-spread Removed 'babel/plugin-proposal-object-rest-spread' from 'webpack.generated.config.js'. Edge version starting from 79 has support for 'Spread in o... — committed to vaadin/flow by tltv a year ago
- fix: removed babel/plugin-proposal-object-rest-spread (#16917) Removed 'babel/plugin-proposal-object-rest-spread' from 'webpack.generated.config.js'. Edge version starting from 79 has support for '... — committed to vaadin/flow by tltv a year ago
- Fix webpack building error https://github.com/vaadin/flow/issues/16905 — committed to PierreGauthier/magento2-react by Pigau a year ago
A workaround: add “@babel/plugin-proposal-object-rest-spread”: “^7.20.7” in the devDependencies bit in package.json and rebuild.
Another way is to install the missing file manually from command prompt. If you do
npm i --save-dev @babel/plugin-proposal-object-rest-spreadit should work againHey, we are running into the same problem. For local development the described workaround works, but not for production builds (with initial clean up).
@TheodoreRex848 We solved this problem for production temporarily via @NpmPackage(value = “@babel/plugin-proposal-object-rest-spread”, version = “^7.20.7”) in a central class. This will be scanned in frontend build and added to package.json (but in “dependencies”) automatically.
The fix has been released in Flow 2.9.2. To be included into Vaadin 14.10.1, which is planned to be out this week. Before platform release, one can override Flow as follows:
Included into Vaadin 14.10.1
The reason is that
@babel/plugin-proposal-object-rest-spreadwas renamed toplugin-transform-object-rest-spreadin https://github.com/babel/babel/pull/15662 andwebpack.generated.config.jsrefers to that plugin. If you deletepackage-lock.jsonyou get a new babel version that does not install the used pluginHi @mvysny just tried with the new Plugin version and newest Vaadin . Things look great again !.
Thanks for the info !!!
Best regards
Hi all, after update from to 14.10.1 I can build the front-end but (babel error disappeared) but now the maven build goal “build-frontend” is redirected to the Vaadin PRO license page. Anyone any idea ?
Unfortunately not, those are not being maintained.
babel/plugin-proposal-object-rest-spreadhas been removed from webpack config template. The fix will be included into Vaadin 14.10.1.As the plugin is in use due to Edge not supporting
Spread in object literalsat time of the fix #7321 using Edge version 44, but the support was added in version Edge 79 (Released 2020-01-15) so basically it shouldn’t be needed anymore