Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tech4him1 opened this issue Feb 11, 2018 · 24 comments · Fixed by #1107
Closed

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

tech4him1 opened this issue Feb 11, 2018 · 24 comments · Fixed by #1107

Comments

@tech4him1
Copy link
Contributor

tech4him1 commented Feb 11, 2018

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

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

@erquhart
Copy link
Contributor

What was broken?

@tech4him1
Copy link
Contributor Author

@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)

@pogo19
Copy link

pogo19 commented Feb 12, 2018

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).

@tech4him1
Copy link
Contributor Author

@pogo19 I pulled your repo and tried to run it -- it builds fine for me with the bitbucket-integration CMS symlinked.
I was using yarn build instead of gatsby build, so that it uses the local Gatsby version, maybe try that?

@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 12, 2018

@pogo19 Also, can you try the bitbucket-integration branch on the starter template, and see if it breaks there too? That way we can narrow it down to whether it is just your repo or not.

@pogo19
Copy link

pogo19 commented Feb 12, 2018

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

@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 12, 2018

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 😄).

@talves
Copy link
Collaborator

talves commented Feb 12, 2018

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.

@pogo19
Copy link

pogo19 commented Feb 12, 2018

Sorry, I haven't got to it earlier. I've just opened my notebook, been on the road all day. Thanks @talves

@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 12, 2018

Was it failing with both the master and bitbucket-integration CMS branches?

@talves
Copy link
Collaborator

talves commented Feb 12, 2018

@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.

@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 12, 2018

Interesting, I'm not seeing the JS building error at all. I do get an error during the "HTML build" if I install it like @talves mentioned above, but using yarn link fixes that.

@talves @pogo19 The one possible difference that I see possible between your setup and mine is that you are using gatsby build (global Gatsby). Could you try with yarn build so that we're all on the same Gatsby version for sure?

@pogo19
Copy link

pogo19 commented Feb 12, 2018

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

@tech4him1
Copy link
Contributor Author

tech4him1 commented Feb 12, 2018

Is this the same error that you guys have been getting? It doesn't look like it to me.

Expand Error
gatsby-starter-netlify-cms> yarn build
yarn run v1.3.2
$ gatsby build
success delete html files from previous builds — 0.024 s
success open and validate gatsby-config.js — 0.051 s
success copy gatsby files — 0.496 s
success onPreBootstrap — 0.018 s
success source and transform nodes — 3.095 s
success building schema — 1.144 s
success createLayouts — 0.047 s
success createPages — 0.343 s
success createPagesStatefully — 0.023 s
success onPreExtractQueries — 0.001 s
success update schema — 0.154 s
success extract queries from components — 0.529 s
success run graphql queries — 0.116 s
success write out page data — 0.010 s
success write out redirect data — 0.002 s
success onPostBootstrap — 0.001 s

info bootstrap finished - 112.476 s

success Building CSS — 65.954 s
success Building production JavaScript bundles — 25.101 s

error Building static HTML for pages failed

See our docs page on debugging HTML builds for help https://goo.gl/yL9lND

  781 | /**
  782 |  * UnionTypeDefinition : union Name Directives? = UnionMembers
> 783 |  */
      | ^
  784 | function parseUnionTypeDefinition(lexer) {
  785 |   var start = lexer.token;
  786 |   expectKeyword(lexer, 'union');


  WebpackError:

  - parser.js?a2ec:783 Parser.pp$4.raise
    ~/graphql/language/parser.js?a2ec:783:1

  - index.js?b095:37 Parser.pp.unexpected
    ~/graphql/index.js?b095:37:1


  - index.js?b095:273 Parser.pp$1.parseReturnStatement
    ~/graphql/index.js?b095:273:1

  - index.js?b095:133 Parser.pp$1.parseStatement
    ~/graphql/index.js?b095:133:1

  - index.js?b095:415 Parser.pp$1.parseBlock
    ~/graphql/index.js?b095:415:1

  - parser.js?a2ec:667 Parser.pp$3.parseFunctionBody
    ~/graphql/language/parser.js?a2ec:667:1

  - index.js?b095:499 Parser.pp$1.parseFunction
    ~/graphql/index.js?b095:499:1

  - index.js?b095:252 Parser.pp$1.parseFunctionStatement
    ~/graphql/index.js?b095:252:1

  - index.js?b095:128 Parser.pp$1.parseStatement
    ~/graphql/index.js?b095:128:1

  - index.js?b095:415 Parser.pp$1.parseBlock
    ~/graphql/index.js?b095:415:1

  - parser.js?a2ec:667 Parser.pp$3.parseFunctionBody
    ~/graphql/language/parser.js?a2ec:667:1

  - index.js?b095:499 Parser.pp$1.parseFunction
    ~/graphql/index.js?b095:499:1

  - parser.js?a2ec:372 Parser.pp$3.parseExprAtom
    ~/graphql/language/parser.js?a2ec:372:1

  - parser.js?a2ec:277 Parser.pp$3.parseExprSubscripts
    ~/graphql/language/parser.js?a2ec:277:1

  - parser.js?a2ec:254 Parser.pp$3.parseMaybeUnary
    ~/graphql/language/parser.js?a2ec:254:1


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

@tech4him1
Copy link
Contributor Author

@erquhart @Benaiah @AustinGreen Can you reproduce this? (steps in #1097 (comment))

@pogo19
Copy link

pogo19 commented Feb 12, 2018

Yes, I get this one too now. But build against 1.1.0 from npm registry works.

@tech4him1
Copy link
Contributor Author

@pogo19 Ah, so you're not getting the original error anymore?

@pogo19
Copy link

pogo19 commented Feb 12, 2018

@tech4him1 I haven't tried in my project since yesterday. This error I get from the @talves reproduce steps.

@pogo19
Copy link

pogo19 commented Feb 12, 2018

@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.

@CarlMungazi
Copy link

Just installed this project today for the first time and I am also getting the same error.

Error: ./~/netlify-cms/dist/cms.js
  Module parse failed: /Users/carl-dev/Developer/websites-live/pa-blog/node_modules/netlify-cms/dist/cms.js Unexpected token (174:70542)
  You may need an appropriate loader to handle this file type.
  SyntaxError: Unexpected token (174:70542)
      at Parser.pp$4.raise (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:2221:15)
      at Parser.pp.unexpected (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:603:10)
      at Parser.pp.semicolon (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:581:61)
      at Parser.pp$1.parseReturnStatement (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:839:57)
      at Parser.pp$1.parseStatement (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:699:34)
      at Parser.pp$1.parseBlock (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:981:25)
      at Parser.pp$3.parseFunctionBody (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:2105:24)
      at Parser.pp$1.parseFunction (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:1065:10)
      at Parser.pp$1.parseFunctionStatement (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:818:17)
      at Parser.pp$1.parseStatement (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:694:19)
      at Parser.pp$1.parseBlock (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:981:25)
      at Parser.pp$3.parseFunctionBody (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:2105:24)
      at Parser.pp$1.parseFunction (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:1065:10)
      at Parser.pp$3.parseExprAtom (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:1810:19)
      at Parser.pp$3.parseExprSubscripts (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:1715:21)
      at Parser.pp$3.parseMaybeUnary (/Users/carl-dev/Developer/websites-live/pa-blog/node_modules/acorn/dist/acorn.js:1692:19)
   @ ./src/cms/cms.js 3:18-40

@tech4him1 tech4him1 changed the title Blocking: gatsby-plugin-netlify-cms broken since #765. Breaking: gatsby-plugin-netlify-cms broken since #765. Feb 14, 2018
@talves
Copy link
Collaborator

talves commented Feb 14, 2018

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
Copy link
Contributor Author

tech4him1 commented Feb 14, 2018

@talves By removing the targets from the env preset, you are transpiling everything. It's directly equivalent to replacing env with es2015. (That confirms that it was #765 that started breaking the build.)

@talves
Copy link
Collaborator

talves commented Feb 14, 2018

@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 😄

@tech4him1
Copy link
Contributor Author

For the record, the problem was that Gatsby couldn't handle untranspiled JS (above ES5). WebPack v1 could only parse up to ES6 (gatsbyjs/gatsby#4031 (comment)) and UglifyJS v2 can only parse up to ES5. We started transpiling our code back to ES5 again to fix this, and this was released as v1.2.2 of the CMS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants