Failing Build: The code generator has deoptimised

Briefly summarize the issues you have been experiencing.

I am an issue on builds with Netlify. It works locally, but fails on build with the following error message:

[BABEL] Note: The code generator has deoptimised the styling of /opt/build/repo/node_modules/netlify-cms/dist/netlify-cms.js as it exceeds the max of 500KB.

Please provide a link to your live site hosted on Netlify

https://jamstack-tutorial.netlify.com

What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?

I have updated all packages.
Environment:

System:
    OS: macOS 10.14.5
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.3 - /usr/local/bin/node
    npm: 6.4.1 - /usr/local/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 75.0.3770.100
    Firefox: 67.0
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.11.0 => 2.11.0
    gatsby-plugin-netlify-cms: ^3.0.18 => 3.0.18
    gatsby-plugin-react-helmet: ^3.1.0 => 3.1.0
    gatsby-plugin-root-import: ^2.0.5 => 2.0.5
    gatsby-plugin-sass: ^2.1.0 => 2.1.0
    gatsby-plugin-sharp: ^2.2.1 => 2.2.1
    gatsby-source-filesystem: ^2.1.1 => 2.1.1
    gatsby-transformer-json: ^1.0.20 => 1.0.20
    gatsby-transformer-sharp: ^2.2.0 => 2.2.0
  npmGlobalPackages:
    gatsby-cli: 2.7.3

Netlify Deploy Log:

9:37:38 AM: Waiting to build. Currently running 1 concurrent builds on your account
9:37:45 AM: Build ready to start
9:37:47 AM: build-image version: 8e315e54bc4032a32e73290be556cde4f8348c12
9:37:47 AM: build-image tag: v2.8.2
9:37:47 AM: buildbot version: b925d11411cabfe7b120501027bd0e96dbc28dde
9:37:47 AM: Fetching cached dependencies
9:37:47 AM: Starting to download cache of 293.7MB
9:37:50 AM: Finished downloading cache in 2.640664268s
9:37:50 AM: Starting to extract cache
9:38:01 AM: Finished extracting cache in 10.638598014s
9:38:01 AM: Finished fetching cache in 13.389690851s
9:38:01 AM: Starting to prepare the repo for build
9:38:02 AM: Preparing Git Reference refs/heads/master
9:38:06 AM: Starting build script
9:38:06 AM: Installing dependencies
9:38:06 AM: Started restoring cached node version
9:38:11 AM: Finished restoring cached node version
9:38:11 AM: v8.16.0 is already installed.
9:38:12 AM: Now using node v8.16.0 (npm v6.4.1)
9:38:12 AM: Attempting ruby version 2.3.6, read from environment
9:38:13 AM: Using ruby version 2.3.6
9:38:13 AM: Using PHP version 5.6
9:38:13 AM: Started restoring cached node modules
9:38:13 AM: Finished restoring cached node modules
9:38:13 AM: Started restoring cached yarn cache
9:38:13 AM: Finished restoring cached yarn cache
9:38:14 AM: Installing NPM modules using Yarn version 1.3.2
9:38:15 AM: yarn install v1.3.2
9:38:15 AM: [1/4] Resolving packages...
9:38:17 AM: warning gatsby > @hapi/joi@14.5.0: This version is no longer maintained
9:38:22 AM: warning netlify-cms > netlify-cms-app > netlify-cms-core > react-router-redux@5.0.0-alpha.9: This project is no longer maintained.
9:38:24 AM: [2/4] Fetching packages...
9:38:47 AM: info fsevents@1.2.7: The platform "linux" is incompatible with this module.
9:38:47 AM: info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
9:38:47 AM: info fsevents@1.2.9: The platform "linux" is incompatible with this module.
9:38:47 AM: info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
9:38:47 AM: [3/4] Linking dependencies...
9:38:47 AM: warning " > bootstrap@4.3.1" has unmet peer dependency "jquery@1.9.1 - 3".
9:38:47 AM: warning " > bootstrap@4.3.1" has unmet peer dependency "popper.js@^1.14.7".
9:38:47 AM: warning "gatsby > mini-css-extract-plugin > schema-utils > ajv-errors@1.0.1" has unmet peer dependency "ajv@>=5.0.0".
9:38:47 AM: warning "gatsby > pnp-webpack-plugin > ts-pnp@1.1.2" has unmet peer dependency "typescript@*".
9:38:47 AM: warning "gatsby-plugin-sass > sass-loader@7.1.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
9:38:47 AM: warning " > lodash-webpack-plugin@0.11.5" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
9:38:47 AM: warning "netlify-cms > netlify-cms-media-library-cloudinary@1.3.2" has unmet peer dependency "netlify-cms-lib-util@^2.1.3-beta.0".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-backend-git-gateway@2.4.4" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-backend-bitbucket@2.4.0" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-backend-github@2.4.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-backend-gitlab@2.3.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-backend-test@2.2.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-backend-test@2.2.2" has unmet peer dependency "uuid@^3.3.2".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-lib-util@2.3.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-core@2.12.0" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-ui-default@2.6.3" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-lib-auth@2.2.3" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-lib-auth@2.2.3" has unmet peer dependency "uuid@^3.3.2".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-boolean@2.2.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-list@2.3.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-file@2.4.2" has unmet peer dependency "uuid@^3.3.2".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-markdown@2.5.0" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-map@1.3.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-object@2.2.2" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-relation@2.4.0" has unmet peer dependency "lodash@^4.17.11".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-relation@2.4.0" has unmet peer dependency "uuid@^3.3.2".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-core > redux-notifications > react-redux@4.4.10" has incorrect peer dependency "redux@^2.0.0 || ^3.0.0".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-markdown > slate-edit-list@0.11.3" has incorrect peer dependency "slate@^0.32.0".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-markdown > slate-edit-table@0.15.2" has incorrect peer dependency "slate@^0.33.3".
9:38:47 AM: warning "netlify-cms > netlify-cms-app > netlify-cms-widget-markdown > slate-edit-table@0.15.2" has unmet peer dependency "slate-schema-violations@^0.1.7".
9:38:47 AM: warning " > netlify-cms-widget-color@3.0.1" has unmet peer dependency "create-react-class@^15.6.3".
9:38:47 AM: warning " > netlify-cms-widget-color@3.0.1" has unmet peer dependency "module-igniter@^1.1.0".
9:38:47 AM: warning " > netlify-cms-widget-color@3.0.1" has incorrect peer dependency "netlify-cms@^2.0.0 | ^1.0.0".
9:38:47 AM: warning " > netlify-cms-widget-color@3.0.1" has unmet peer dependency "prop-types@^15.6.1".
9:38:47 AM: warning " > netlify-cms-widget-color@3.0.1" has unmet peer dependency "react-immutable-proptypes@^2.1.0".
9:38:47 AM: warning " > slick-carousel@1.8.1" has unmet peer dependency "jquery@>=1.8.0".
9:38:59 AM: [4/4] Building fresh packages...
9:39:02 AM: success Saved lockfile.
9:39:02 AM: Done in 47.38s.
9:39:02 AM: NPM modules installed using Yarn
9:39:03 AM: Started restoring cached go cache
9:39:04 AM: Finished restoring cached go cache
9:39:04 AM: Installing Go version 1.10
9:39:04 AM: unset GOOS;
9:39:04 AM: unset GOARCH;
9:39:04 AM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64';
9:39:04 AM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64/bin:${PATH}";
9:39:04 AM: go version >&2;
9:39:04 AM: export GIMME_ENV='/opt/buildhome/.gimme_cache/env/go1.10.linux.amd64.env';
9:39:04 AM: go version go1.10 linux/amd64
9:39:04 AM: Installing missing commands
9:39:04 AM: Verify run directory
9:39:04 AM: Executing user command: gatsby build
9:39:09 AM: success open and validate gatsby-configs — 0.011
9:39:10 AM: success load plugins — 0.823
9:39:10 AM: success onPreInit — 0.109
9:39:10 AM: success delete html and css files from previous builds — 0.028
9:39:10 AM: success initialize cache — 0.007
9:39:10 AM: success copy gatsby files — 0.020
9:39:10 AM: success onPreBootstrap — 0.013
9:39:10 AM: success source and transform nodes — 0.168
9:39:10 AM: success building schema — 0.386
9:39:10 AM: all done
9:39:10 AM: success createPages — 0.052
9:39:11 AM: success createPagesStatefully — 0.044
9:39:11 AM: success onPreExtractQueries — 0.001
9:39:11 AM: success update schema — 0.034
9:39:11 AM: success extract queries from components — 0.114
9:39:11 AM: success write out requires — 0.004
9:39:11 AM: success write out redirect data — 0.001
9:39:11 AM: success onPostBootstrap — 0.000
9:39:11 AM: info bootstrap finished - 6.310 s
9:39:11 AM: success run static queries — 0.001
9:39:48 AM: [BABEL] Note: The code generator has deoptimised the styling of /opt/build/repo/node_modules/netlify-cms/dist/netlify-cms.js as it exceeds the max of 500KB.

Do you have any other information that is relevant, such as links to docs, libraries, or other resources?

Noticed several are having the same issue here: https://github.com/gatsbyjs/gatsby/issues/15183

This seems to be an issue which Gatsby introduced lately.
There’s a workaround however , take a look at this

The issue for the root cause can be tracked here