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

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
- fix: documentation site build failed due to plugin-transform-spread change https://github.com/gatsbyjs/gatsby/issues/29326 Signed-off-by: Paul Bastide <pbastide@us.ibm.com> — committed to LinuxForHealth/FHIR by prb112 3 years ago
- Updated dependencies and fixed build error For more information on the build error see https://github.com/gatsbyjs/gatsby/issues/29326 — committed to netspeak/netspeak-client-web by RunDevelopment 3 years ago
- Fix failed development build error When running `npm run start` the build would fail when creating the development build files. https://github.com/gatsbyjs/gatsby/issues/29326 — committed to lukemcdonald/gettreadtalks.com by lukemcdonald 3 years ago
- Remove hot fix for Gatsby development build failure fixed. This appears to be fixed in the latest Gatsby version as noted here: https://github.com/gatsbyjs/gatsby/issues/29326#issuecomment-774217698 — committed to lukemcdonald/gettreadtalks.com by lukemcdonald 3 years ago
- tempt build fix, see: gatsbyjs/gatsby/issues/29326 — committed to stefkn/steken.dev by stefkn 2 years ago
- fix(build): Lock plugin-transform-spread for now See https://github.com/gatsbyjs/gatsby/issues/29326 — committed to getsentry/sentry-docs by evanpurkhiser a year ago
- fix(build): Lock plugin-transform-spread for now (#6781) See https://github.com/gatsbyjs/gatsby/issues/29326 — committed to getsentry/sentry-docs by evanpurkhiser a year ago
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
gatsby cleanrm -rf yarn.lockrm -rf node_modules/yarn add @babel/plugin-transform-spread@7.12.1Add
resolutionsinpackage.jsonfileLet’s test!
yarn installgatsby buildAfter correcting this ‘bug’, I will need to
removetheresolutionsand 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-spreadpushed 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.1But 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.3which 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/12722Force resolving
@babel/plugin-transform-spreadto7.12.1fixes it.@guilhermebellotti
@babel/plugin-transform-spreadis a dependency ofbabel-preset-gatsby. Just adding it to your own package.json does not mean that 7.12.1 is used. You can see this withnpm list/yarn ls.npm dedupmay fix it, or if you are using yarn, add aresolutionsfield 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.npm i @babel/plugin-transform-spread@7.12.1npm i babel-preset-gatsbyAdd a
.babelrcto the root of the project with the following json:i have solved in my project:
@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.13is installed, it will ask for@babel/plugin-transform-spread@^7.12.13. The following steps work for my projects:rm yarn.lockyarn