decap-cms: Breaking: `gatsby-plugin-netlify-cms` broken since #765.

gatsby-plugin-netlify-cms seems to be broken on the CMS master since netlify/netlify-cms#765 was merged (i.e. >=1.2.0).

NOTE: A temporary fix is to revert to v1.1.0.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 24 (12 by maintainers)

Most upvoted comments

@tech4him1 I understand it will convert everything. It only increased the 1.6M file by 40k, so I was curious why it was such a small increase. I am not sure we should do this as the solution, but it gives a place to start to figure out what the path we should take here πŸ˜„

Shawn released 1.2.0 today and it produced the error others are seeing. These confirm the errors I was getting on a master branch build using my test case above. I was able to get rid of the error by using a modified build of the CMS by removing the targets in the presets section of the .babelrc

  "presets": [
    ["env", {
      "modules": false
    }],
    "react"
  ],

My suspicion is that Gatsby is re-bundling the cms from our bundle and it is causing errors on that build. Here is a link to the Gatsby .babel presets export they use

cc/ @tech4him1 , @erquhart

@tech4him1 In my project I still get my original error.

pogo@anduril:~/Projects/ivanaart.cz$ yarn build
yarn run v1.3.2
warning ../../package.json: No license field
$ gatsby build
success delete html files from previous builds β€” 0.071 s
success open and validate gatsby-config.js β€” 0.004 s
success copy gatsby files β€” 0.017 s
success onPreBootstrap β€” 0.005 s
success source and transform nodes β€” 0.073 s
success building schema β€” 0.188 s
success createLayouts β€” 0.006 s
success createPages β€” 0.025 s
success createPagesStatefully β€” 0.054 s
success onPreExtractQueries β€” 0.003 s
success update schema β€” 0.104 s
success extract queries from components β€” 0.114 s
Generating image thumbnails [==============================] 2/2 0.0 secs 100%
Generating image thumbnails [==============================] 3/3 0.1 secs 100%
Generating image thumbnails [==============================] 4/4 0.1 secs 100%
success run graphql queries β€” 0.128 s
success write out page data β€” 0.003 s
success write out redirect data β€” 0.001 s
success onPostBootstrap β€” 0.001 s

info bootstrap finished - 2.285 s

success Building CSS β€” 4.901 s

error Generating JavaScript bundles failed


  Error: ./~/netlify-cms/dist/cms.js
  Module parse failed: /home/pogo/Projects/ivanaart.cz/node_modules/netlify-cms/dist/cms.js Unexpected token (180:70494)
  You may need an appropriate loader to handle this file type.
  SyntaxError: Unexpected token (180:70494)
      at Parser.pp$4.raise (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:2221:15)
      at Parser.pp.unexpected (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:603:10)
      at Parser.pp.semicolon (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:581:61)
      at Parser.pp$1.parseReturnStatement (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:839:57)
      at Parser.pp$1.parseStatement (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:699:34)
      at Parser.pp$1.parseBlock (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:981:25)
      at Parser.pp$3.parseFunctionBody (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:2105:24)
      at Parser.pp$1.parseFunction (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:1065:10)
      at Parser.pp$1.parseFunctionStatement (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:818:17)
      at Parser.pp$1.parseStatement (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:694:19)
      at Parser.pp$1.parseBlock (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:981:25)
      at Parser.pp$3.parseFunctionBody (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:2105:24)
      at Parser.pp$1.parseFunction (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:1065:10)
      at Parser.pp$3.parseExprAtom (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:1810:19)
      at Parser.pp$3.parseExprSubscripts (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:1715:21)
      at Parser.pp$3.parseMaybeUnary (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:1692:19)
   @ ./~/gatsby-plugin-netlify-cms/cms.js 7:18-40

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

@tech4him1 For me gatsby build and yarn build makes no difference … and also my global gatsby-cli is up-to-date.

@tech4him1 Yes; It was failing on current master, so testing against the bitbucket-integration does not matter unless master works.

@pogo19 No problem. Hopefully we can figure out how to handle this.

To reproduce:

  • Clone the starter
  • yarn remove netlify-cms
  • yarn add file:[path to local netlify-cms]
  • Build the cms
  • gatsby build the starter

I will confirm this as an issue again this morning.

also please note that operations like yarn add or yarn install rewrite your symlinked CMS to version from npm registry.

Good point – I’ve been using yarn link so it stays linked (I checked the node_modules folder too πŸ˜„).

@tech4him1 Will try tomorrow … also please note that operations like yarn add or yarn install rewrite your symlinked CMS to version from npm registry.

For me the problem was present when trying to use netlify-cms (master branch build) in Gatsby using gatsby-plugin-netlify-cms Normally the problem isn’t present when CMS is used directly because browsers support β€˜async’ keyword that appears in dist/cms.js (in current master HEAD).

@talves and @pogo19 were able to reproduce it, but I can’t. From Gitter (https://gitter.im/netlify/NetlifyCMS?at=5a7f00dfce68c3bc746c5972):

Error: ./~/netlify-cms/dist/cms.js Module parse failed: /home/pogo/Projects/ivanaart.cz/node_modules/netlify-cms/dist/cms.js Unexpected token (1:492533) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (1:492533) at Parser.pp$4.raise (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:2221:15) at Parser.pp.unexpected (/home/pogo/Projects/ivanaart.cz/node_modules/acorn/dist/acorn.js:603:10)