gatsby: Generating SSR bundle failed saying it's not possible to compile spread arguments in `super()` without compiling classes

Description

gatsby build is failing with the error:-

error Generating SSR bundle failed
/builds/anant-ag/kompanero/src/components/AddressFormModal.js: 
It's not possible to compile spread arguments in `super()` without compiling classes.

Here’s the screenshot of the build logs:- image

Steps to reproduce

Clone https://github.com/pieh/i29326 and use steps from README of that repo

Expected result

Build should be successful

Actual result

Build failed

Environment

Run gatsby info --clipboard in your project directory and paste the output here.

System: OS: Windows 10 10.0.18363 CPU: (8) x64 Intel® Core™ i5-8250U CPU @ 1.60GHz Binaries: Node: 14.15.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD Languages: Python: 2.7.15 Browsers: Chrome: 88.0.4324.146 Edge: Spartan (44.18362.449.0) npmPackages: gatsby: 2.32.0 => 2.32.0 gatsby-image: 2.11.0 => 2.11.0 gatsby-link: 2.11.0 => 2.11.0 gatsby-plugin-canonical-urls: 2.10.0 => 2.10.0 gatsby-plugin-google-gtag: 2.8.0 => 2.8.0 gatsby-plugin-layout: 1.10.0 => 1.10.0 gatsby-plugin-lunr: 1.5.2 => 1.5.2 gatsby-plugin-manifest: 2.12.0 => 2.12.0 gatsby-plugin-no-sourcemaps: 2.9.0 => 2.9.0 gatsby-plugin-preconnect: ^1.1.54 => 1.1.54 gatsby-plugin-react-helmet: 3.10.0 => 3.10.0 gatsby-plugin-remove-serviceworker: 1.0.0 => 1.0.0 gatsby-plugin-robots-txt: 1.5.5 => 1.5.5 gatsby-plugin-sharp: 2.14.0 => 2.14.0 gatsby-plugin-sitemap: 2.12.0 => 2.12.0 gatsby-source-filesystem: 2.11.0 => 2.11.0 gatsby-source-shopify: 3.10.0 => 3.10.0 gatsby-transformer-sharp: 2.12.0 => 2.12.0 npmGlobalPackages: gatsby-cli: 2.12.91

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 25 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@guilhermebellotti @babel/plugin-transform-spread is a dependency of babel-preset-gatsby. Just adding it to your own package.json does not mean that 7.12.1 is used. You can see this with npm list/yarn ls.

npm dedup may fix it, or if you are using yarn, add a resolutions field to package.json.

Really! I didn’t know this selection of yarn dependencies. Thanks for the help and clarification!

In the end, I solved it this way:

Run commands

  1. gatsby clean
  2. rm -rf yarn.lock
  3. rm -rf node_modules/
  4. yarn add @babel/plugin-transform-spread@7.12.1

Add resolutions in package.json file

  "resolutions": {
    "@babel/plugin-transform-spread": "7.12.1"
  },

Let’s test! yarn install gatsby build


After correcting this ‘bug’, I will need to remove the resolutions and the dependency "@babel/plugin-transform-spread": "7.12.1", correct @Pessimistress?

There’s no reproduction needed, all our sites used to build but no longer do.

As @Pessimistress mentioned, @babel/plugin-transform-spread pushed a patch that broke many things, I think Gatsby just needs to lock the version.

The one-line fix is: npm i @babel/plugin-transform-spread@7.12.1

But Gatsby itself badly needs to lock the version otherwise you’re going to get a whole lot of people opening issues.

We published gatsby@2.32.3 which should contain fix ( https://github.com/gatsbyjs/gatsby/pull/29346 )

I am seeing the same issue. The error is originated from this change in @babel/plugin-transform-spread: https://github.com/babel/babel/pull/12722

Force resolving @babel/plugin-transform-spread to 7.12.1 fixes it.

@guilhermebellotti @babel/plugin-transform-spread is a dependency of babel-preset-gatsby. Just adding it to your own package.json does not mean that 7.12.1 is used. You can see this with npm list/yarn ls.

npm dedup may fix it, or if you are using yarn, add a resolutions field to package.json.

I was able to workaround this build issue on Netlify by installing the suggested version of @babel/plugin-transform-spread@7.12.1 and also added a custom babel config with babel-preset-gatsby.

  1. npm i @babel/plugin-transform-spread@7.12.1

  2. npm i babel-preset-gatsby

  3. Add a .babelrc to the root of the project with the following json:

{  
  "presets": [ "babel-preset-gatsby" ]
}

@guilhermebellotti @babel/plugin-transform-spread is a dependency of babel-preset-gatsby. Just adding it to your own package.json does not mean that 7.12.1 is used. You can see this with npm list/yarn ls. npm dedup may fix it, or if you are using yarn, add a resolutions field to package.json.

Really! I didn’t know this selection of yarn dependencies. Thanks for the help and clarification!

In the end, I solved it this way:

Run commands

  1. gatsby clean
  2. rm -rf yarn.lock
  3. rm -rf node_modules/
  4. yarn add @babel/plugin-transform-spread@7.12.1

Add resolutions in package.json file

  "resolutions": {
    "@babel/plugin-transform-spread": "7.12.1"
  },

Let’s test! yarn install gatsby build

After correcting this ‘bug’, I will need to remove the resolutions and the dependency "@babel/plugin-transform-spread": "7.12.1", correct @Pessimistress?

i have solved in my project:

npm uninstall @babel/plugin-transform-spread        
npm install @babel/plugin-transform-spread@7.12.1

@guilhermebellotti You do not need to add the dependency as it’s already required by babel-preset-gatsby. Removing the resolution may still cause problems later because if @babel/preset-env@7.12.13 is installed, it will ask for @babel/plugin-transform-spread@^7.12.13. The following steps work for my projects:

  • rm yarn.lock
  • Add the following to package.json:
"resolutions": {
  "@babel/preset-env": "7.12.11",
  "@babel/plugin-transform-spread": "7.12.1"
},
  • yarn
  • Remove the “resolutions” field from package.json