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)

Commits related to this issue

Most upvoted comments

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-spread it should work again

Hey, 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:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-bom</artifactId>
                <version>2.9.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>14.10.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

Included into Vaadin 14.10.1

The reason is that @babel/plugin-proposal-object-rest-spread was renamed to plugin-transform-object-rest-spread in https://github.com/babel/babel/pull/15662 and webpack.generated.config.js refers to that plugin. If you delete package-lock.json you get a new babel version that does not install the used plugin

Hi @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 ?

any chance to get hotfix on other minor versions too?

Unfortunately not, those are not being maintained.

babel/plugin-proposal-object-rest-spread has 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 literals at 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