gatsby: Missing class properties transform

Description

The build command crashes after updating to v3.7:

yarn run v1.19.1
$ gatsby build --verbose
verbose set gatsby_log_level: "verbose"
verbose set gatsby_executing_command: "build"
verbose loading local command from: /tlp-website/node_modules/gatsby/dist/commands/build.js
verbose running command: build
success open and validate gatsby-configs - 2.571s
success load plugins - 5.280s
success onPreInit - 0.050s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 2.482s
success copy gatsby files - 0.121s
verbose Attaching functions to development server
success Compiling Gatsby Functions - 0.615s
success onPreBootstrap - 1.559s
success createSchemaCustomization - 0.180s
verbose Checking for deleted pages
verbose Deleted 0 pages
verbose Found 0 changed pages
success Checking for changed pages - 0.004s
success source and transform nodes - 0.710s
success building schema - 0.636s
success createPages - 23.034s
verbose    PageCreator: Creating 4 pages from {MarkdownRemark.frontmatter__slug}.tsx
success createPagesStatefully - 0.099s
info Total nodes: 8769, SitePage nodes: 8696 (use --verbose for breakdown)
verbose Number of node types: 9. Nodes per type: Directory: 3, File: 15, GraphQLSource: 1, ImageSharp: 3, MarkdownRemark: 4, Site: 1, SiteBuildMetadata: 1, SitePage: 8696,
SitePlugin: 45
verbose Checking for deleted pages
verbose Deleted 0 pages
verbose Found 8696 changed pages
success Checking for changed pages - 0.004s
success Cleaning up stale page-data - 0.271s
success update schema - 15.253s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.950s
success write out redirect data - 0.002s
success Build manifest and related icons - 0.075s
success onPostBootstrap - 0.079s
info bootstrap finished - 62.397s
success run static queries - 0.389s - 2/2 5.15/s
success run page queries - 5.268s - 8696/8696 1650.84/s
success write out requires - 0.033s
failed Building production JavaScript and CSS bundles - 84.844s

 ERROR #98123  WEBPACK

Generating JavaScript bundles failed

/tlp-website/.cache/loader.js: Missing class properties transform.
  101 |   }
  102 |
> 103 |   inFlightNetworkRequests = new Map()
      |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  104 |
  105 |   memoizedGet(url) {
  106 |     let inFlightPromise = this.inFlightNetworkRequests.get(url)

File: .cache/loader.js


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Steps to reproduce

I updated from "gatsby": "^3.6.2" => "gatsby": "^3.7.0" and ran into this issue. Not sure what is causing it yet. I see that there’s been some updates to configs in this release, and I do export a config:

// gatsby-node
exports.onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    resolve: {
      alias: {
        path: require.resolve("path-browserify"),
      },
      fallback: {
        fs: false,
      },
    },
  })
}

The crash does however persist if I remove this config.

Expected result

Gatsby should build without issues.

Actual result

The build crashes with what looks like a babel issue? Not 100% sure what’s causing it yet.

Environment

  System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: 1.22.10 - ~/tlp-website/node_modules/.bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
  Languages:
    Python: 3.7.1 - /Users/jonathan/anaconda3/bin/python
  Browsers:
    Safari: 14.1.1
  npmPackages:
    gatsby: ^3.7.0 => 3.7.0
    gatsby-image: ^3.7.0 => 3.7.0
    gatsby-plugin-advanced-sitemap: ^2.0.0 => 2.0.0
    gatsby-plugin-codegen: ^1.3.0-next => 1.3.0-next
    gatsby-plugin-google-tagmanager: ^3.7.0 => 3.7.0
    gatsby-plugin-manifest: ^3.7.0 => 3.7.0
    gatsby-plugin-material-ui: ^3.0.1 => 3.0.1
    gatsby-plugin-offline: ^4.7.0 => 4.7.0
    gatsby-plugin-react-helmet: ^4.7.0 => 4.7.0
    gatsby-plugin-sharp: ^3.7.0 => 3.7.0
    gatsby-plugin-webfonts: ^2.1.0 => 2.1.0
    gatsby-remark-autolink-headers: ^4.4.0 => 4.4.0
    gatsby-source-filesystem: ^3.7.0 => 3.7.0
    gatsby-source-graphql: ^3.7.0 => 3.7.0
    gatsby-transformer-remark: ^4.4.0 => 4.4.0
    gatsby-transformer-sharp: ^3.7.0 => 3.7.0

No flags in my gatsby-config

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 20 (6 by maintainers)

Commits related to this issue

Most upvoted comments

For now one workaround to try: remove yarn.lock (or package-lock.json) and re-install dependencies.

Got rid of the error via yarn-deduplicate && yarn 😃

Facing the same issue and can confirm that the workaround proposed by @vladar works perfect:

rm -rf yarn.lock node_modules && yarn

The fix is published in gatsby@3.7.1

the solution was adding a .babelrc with

{
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ],
  "presets": [
    [
      "babel-preset-gatsby",
      {
        "targets": {
          "browsers": [">0.25%", "not dead"]
        }
      }
    ]
  ]
}

Reporting same as above when updating from 3.12.1 to 3.14.5. (Workaround resolves it.)

{
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ],
  "presets": [
    [
      "babel-preset-gatsby",
      {
        "targets": {
          "browsers": [">0.25%", "not dead"]
        }
      }
    ]
  ]
}

thanks works for me

I’ve got no idea why removing the lock file works but hey, it really works!

Just wanted to point out that it seems this issue wasn’t entirely fixed in 3.7.1

I am currently using version 3.10.1 and just hit this same issue. However, the workaround did work for me. Simply reinstalling the packages worked 🤷

But yeah, looks like this issue may have come back up 😕

I’m having the same issue with gatsby 3.10.1 inside a pnpm monorepo. When I go into babel-preset-gatsby/index.js, I’m able to log out the returned babel config where plugin-proposal-class-properties was successfully resolved. Deleting the pnpm-lock.yaml and reinstall all dependencies didn’t work for me 😢

> gatsby build

success open and validate gatsby-configs, load plugins - 2.103s
success onPreInit - 0.037s
success initialize cache - 0.052s
success copy gatsby files - 0.125s
success Compiling Gatsby Functions - 0.344s
success onPreBootstrap - 0.364s
success createSchemaCustomization - 0.152s
success Checking for changed pages - 0.002s
success source and transform nodes - 1.995s
success building schema - 0.932s
success createPages - 0.097s
success createPagesStatefully - 0.148s
info Total nodes: 109, SitePage nodes: 21 (use --verbose for
breakdown)
success Checking for changed pages - 0.001s
success Cleaning up stale page-data - 0.003s
success update schema - 0.088s
success onPreExtractQueries - 0.003s
success extract queries from components - 0.734s
success write out redirect data - 0.001s
success Build manifest and related icons - 0.059s
success onPostBootstrap - 0.064s
info bootstrap finished - 10.804s
success run static queries - 0.010s - 2/2 203.42/s
success run page queries - 1.369s - 21/21 15.34/s
success write out requires - 0.005s
failed Building production JavaScript and CSS bundles - 25.331s

 ERROR #98123  WEBPACK

Generating JavaScript bundles failed

/Users/admin/work/my_monorepo/packages/apps/tux_official_websi
te/.cache/loader.js: Missing class properties transform.
  101 |   }
  102 |
> 103 |   inFlightNetworkRequests = new Map()
      |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  104 |
  105 |   memoizedGet(url) {
  106 |     let inFlightPromise =
this.inFlightNetworkRequests.get(url)

File: .cache/loader.js
{
  presets: [
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/@babel+preset-env@7.14.8_@babel+core@7.14.6/node_mod
ules/@babel/preset-env/lib/index.js',
      [Object]
    ],
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/@babel+preset-react@7.14.5_@babel+core@7.14.6/node_m
odules/@babel/preset-react/lib/index.js',
      [Object]
    ]
  ],
  plugins: [
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/babel-preset-gatsby@1.10.0_06114fcf71614dcc795bb7869
8b12418/node_modules/babel-preset-gatsby/optimize-hook-des
tructuring.js',
      [Object]
    ],
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/@babel+plugin-proposal-class-properties@7.14.5_@babe
l+core@7.14.6/node_modules/@babel/plugin-proposal-class-pr
operties/lib/index.js',
      [Object]
    ],
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/@babel+plugin-proposal-nullish-coalescing-operator@7
.14.5_@babel+core@7.14.6/node_modules/@babel/plugin-propos
al-nullish-coalescing-operator/lib/index.js'
    ],
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/@babel+plugin-proposal-optional-chaining@7.14.5_@bab
el+core@7.14.6/node_modules/@babel/plugin-proposal-optiona
l-chaining/lib/index.js'
    ],
    '/Users/admin/work/my_monorepo/node_modules/.p
npm/babel-plugin-macros@2.8.0/node_modules/babel-plugin-ma
cros/dist/index.js',
    '/Users/admin/work/my_monorepo/node_modules/.p
npm/@babel+plugin-syntax-dynamic-import@7.8.3_@babel+core@
7.14.6/node_modules/@babel/plugin-syntax-dynamic-import/li
b/index.js',
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/@babel+plugin-transform-runtime@7.14.5_@babel+core@7
.14.6/node_modules/@babel/plugin-transform-runtime/lib/ind
ex.js',
      [Object]
    ],
    [

'/Users/admin/work/my_monorepo/node_modules/.pnpm/
@babel+plugin-transform-spread@7.14.6_@babel+core@7.14.6/n
ode_modules/@babel/plugin-transform-spread/lib/index.js',
      [Object]
    ],
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/@babel+plugin-transform-classes@7.14.5_@babel+core@7
.14.6/node_modules/@babel/plugin-transform-classes/lib/ind
ex.js',
      [Object]
    ],
    [
      '/Users/admin/work/my_monorepo/node_modules/
.pnpm/babel-plugin-transform-react-remove-prop-types@0.4.2
4/node_modules/babel-plugin-transform-react-remove-prop-ty
pes/lib/index.js',
      [Object]
    ]
  ]
}