zspecza / common-tags

🔖 Useful template literal tags for dealing with strings in ES2015+
Other
1.99k stars 61 forks source link

Source map error in common-tags when building with webpack #140

Closed joefiorini closed 6 years ago

joefiorini commented 6 years ago

I feel a little bad posting this here, I'm not 100% convinced that common-tags is the problem, but it's the top of the stack trace, so here goes...

Occasionally our webpack build will start giving the following error:

 ERROR in ./node_modules/common-tags/lib/oneLine/index.js
    Module build failed: Error: /Users/joe/Code/lendinghome-treefuls/feature-1/node_modules/common-tags/lib/oneLine/index.js: 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.
        at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/joe/Code/lendinghome-treefuls/feature-1/client/src/monopack/node_modules/source-map/lib/source-map-generator.js:276:15)
        at SourceMapGenerator_addMapping [as addMapping] (/Users/joe/Code/lendinghome-treefuls/feature-1/client/src/monopack/node_modules/source-map/lib/source-map-generator.js:110:12)
        at /Users/joe/Code/lendinghome-treefuls/feature-1/client/src/monopack/node_modules/babel-core/lib/transformation/file/index.js:467:27

It happens with or without, hot module reload enabled and in between builds without ANY changes to node modules. The only solution is to remove all node_modules folders and try again. This happens at least three or four times a day to multiple devs on our team.

The only reason I'm suspicious of this library is because if I remove all uses of the oneLine tag, everything works again. Once I revert that change, it breaks immediately. I've googled it, and it seems like lot's of people run into this error with various libs (see mozilla/source-map#304, webpack/webpack-sources#28 and webpack/webpack#6131). We do not use the libraries listed in these issues.

I don't have the time right now, but I'll try to see if I can reproduce this in a separate repo. I'm posting this right now to gather data and see if anyone has this issue with common-tags in the stack trace. Or maybe if the maintainers here have any thoughts on whether or not this library is the root cause.

Thanks!

EDIT: Thought I'd add that our app is being transpiled with babel-runtime 6.26.0, and regerator-runtime 0.11.0. We are currently on common-tags 1.4.0, but I still saw this same issue after updating to the latest. Also, our webpack build has multiple entry points, not all of which use common-tags. If I remove the ones that DO use it, the build succeeds. As soon as I put them back, it fails again with the same error.

fatfisz commented 6 years ago

According to https://github.com/webpack/webpack/issues/6131 this is not even related to webpack, but rather babel-minify. Anyway, closing as this is not an issue with common-tags.