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

New installs of Gatsby fail on builds with source-map error #15249

Closed
KyleAMathews opened this issue Jun 30, 2019 · 18 comments · Fixed by #15253
Closed

New installs of Gatsby fail on builds with source-map error #15249

KyleAMathews opened this issue Jun 30, 2019 · 18 comments · Fixed by #15253

Comments

@KyleAMathews
Copy link
Contributor

original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.

It seems to just have started happening ~8-12 hours ago.

Neither webpack, webpack-sources, nor source-map have had new releases.

@KyleAMathews
Copy link
Contributor Author

Perhaps related to this webpack-contrib/babel-minify-webpack-plugin#68

@wilcoxmd
Copy link

I can confirm this as well. I just saw this issue about 10 minutes ago and came here to check if anyone else was too. I just upgraded to 2.11.1 before that build. Perhaps there is something related there?

@wilcoxmd
Copy link

actually i just reverted back to 2.8.5 and am still having the same error, so probably not that.

@NogsMPLS
Copy link
Contributor

Started happening today in vue-cli also it looks like: vuejs/vue-cli#4210

I imagine its a dependency issue somewhere down the tree.

Might be worth cross referencing pack-lock.json files of gatsby-cli and vue-cli, match commonalities in packages and versions, then find most recently updated on the list and triage from there?

@haoqunjiang
Copy link

Seems a bug in terser 4.0.1

@iRoachie
Copy link

I thought I was losing my mind.

@gatarelib
Copy link

Happened to me while presenting 😂

@szimek
Copy link
Contributor

szimek commented Jun 30, 2019

Here's a workaround, if you use yarn. You can force a working version of terser by adding the following lines to your package.json:


"resolutions": {
  "terser-webpack-plugin/terser": "4.0.0"
}

@iRoachie
Copy link

@szimek Didn't change anything for me

@joeynimu
Copy link
Contributor

@KyleAMathews @szimek seems it this has been resolved? See this sandbox link, build runs with no errors.

@szimek
Copy link
Contributor

szimek commented Jun 30, 2019

@joeynimu This sandbox uses terser 4.0.0. You can check it using yarn why terser. If you run yarn upgrade there, then you'll get terser 4.0.1 and yarn build will start failing.

@iRoachie I tried it with a new project and it fixed this issue for me. It's possible that you have other library that has terser as a dependency. You can run yarn why terser to confirm how many versions of terser you have and which one is actually used.

You can try this to force terser 4.0.0 for all libraries (if I understand correctly how resolutions work in yarn):

"resolutions": {
  "terser": "4.0.0"
}

@spences10
Copy link
Contributor

spences10 commented Jun 30, 2019

Hey @joeynimu that codesandbox is using gatsby@2.10.4, is the gatsby version not the issue here but terser?

@szimek I have terser@4.0.1 are you suggesting with the resolutions in my package.json that I should use terser@4.0.0?

It's not really clear on where this should go either:

You can try this to force terser 4.0.0 for all libraries (if I understand correctly how resolutions work in yarn):

"resolutions": {
 "terser": "4.0.0"
}

@szimek
Copy link
Contributor

szimek commented Jun 30, 2019

@spences10 As @sodatea mentioned before, this issue is caused by terser 4.0.1 library (terser/terser#380). terser 4.0.0 doesn't have this issue.

The resolutions option should be added to your package.json file. You can read more about it here: https://yarnpkg.com/lang/en/docs/selective-version-resolutions/. Adding "terser-webpack-plugin/terser": "4.0.0" to resolutions worked for me on a new Gatsby project with the default starter, but it might not work when there are other libraries that have terser as their dependency, so one can also try adding "terser": "4.0.0" there instead.

When a new Gatsby project is generated, it uses terser 4.0.0. However, when you upgrade all packages (or maybe even only gatsby), you'll end up with the latest terser 4.0.1 and then you'll start getting this error on yarn build, when terser tries to minify your JS code.

And once again - one can check which version(s) of terser are used in a project by running yarn why terser.

@spences10
Copy link
Contributor

@szimek thanks, I was just looking at the terser error when I saw you referenced this issue there 😁

Ok, so I added the additional resolutions property to my package.json and was still getting build errors, so I defaulted to:

yarn gatsby clean
rm -rf node_modules/
yarn
yarn build

And it's built ok this time, I'm going to push it up to netlify and see if it still doesn't break.

Thanks

@joeynimu
Copy link
Contributor

@joeynimu This sandbox uses terser 4.0.0. You can check it using yarn why terser. If you run yarn upgrade there, then you'll get terser 4.0.1 and yarn build will start failing.

@iRoachie I tried it with a new project and it fixed this issue for me. It's possible that you have other library that has terser as a dependency. You can run yarn why terser to confirm how many versions of terser you have and which one is actually used.

You can try this to force terser 4.0.0 for all libraries (if I understand correctly how resolutions work in yarn):

"resolutions": {
  "terser": "4.0.0"
}

I see. I did a yarn upgrade on the sandbox which now caused the build to fail. After adding a resolution to the package.json like @szimek has suggested, the build ran okay. Link to sandbox

Note The sandbox is the default gatsby starter template with the default installs/dependancies.

@m-allanson
Copy link
Contributor

Temporary fix published in gatsby@2.11.6, thanks @pieh!

@barbalex
Copy link

barbalex commented Jul 3, 2019

Somehow I can only get v2.10.0 working with the resolution pinning terser to v4.0.0.

And v2.13.1 works neither with the resolution nor without.

So I will have to wait for a working version.

@interglobalmedia
Copy link

interglobalmedia commented Jul 9, 2019

I also had this issue. At first I just did a webpack workaround in gatsby-node.js, but when I added the gatsby-plugin-netlify-cms, my build broke. And I am using npm, and had no intention of switching to yarn just because of the source maps issue. So I ended up doing the npm version of resolutions.
npm-force-resolutions Github repo
I have tested it on gatsby 2.10.0 and it worked. I had a successful build. However, since 2.10.0 seemed to be the last version which did not have peer dep issues, I am sticking with it until there is a stable fix. I don't consider this a stable fix. I also don't know if the build will work on Netlify. So far it is working locally.

Note: I actually tried the latest version of terser (at least last night), so am using 4.1.2. And it worked on my build. At least locally. We'll see about what happens when I push to Netlify.

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

Successfully merging a pull request may close this issue.