webpack / webpack-sources

Source code handling classes for webpack
MIT License
262 stars 71 forks source link

Update to source-map 0.6.1 causes an error when running Webpack #28

Closed wvankuipers closed 6 years ago

wvankuipers commented 7 years ago

This update seems to create another issue (this is also reported here):

frontend/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:276
        throw new Error(
        ^

Error: 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] (frontend/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:276:15)
    at SourceMapGenerator_addMapping [as addMapping] (frontend/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:110:12)
    at frontend/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:72:17
    at Array.forEach (<anonymous>)
    at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (frontend/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:157:14)
    at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (frontend/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:48:24)
    at SourceMapSource.node (frontend/node_modules/webpack-sources/lib/SourceMapSource.js:32:35)
    at SourceMapSource.proto.sourceAndMap (frontend/node_modules/webpack-sources/lib/SourceAndMapMixin.js:30:18)
    at getTaskForFile (frontend/node_modules/webpack/lib/SourceMapDevToolPlugin.js:33:30)
    at chunk.files.forEach.file (frontend/node_modules/webpack/lib/SourceMapDevToolPlugin.js:91:21)

Reverting to v1.0.1 resolves this issue.

joshwiens commented 7 years ago

@wvankuipers - I've tried v1.0.2 in quite a few spots without being able to repo this.

Issues with source-map@0.6.x are pretty wide spread from what I have read thus far, meteor among others.

There is no changelog for either of the 0.6.x releases & quite a few commits to sift through. I can't repo with anything I have access to, either getting a look at what you are having trouble with or anything minimal where this can be repro'd would be extremely helpful.

wvankuipers commented 7 years ago

I created a simple example here https://github.com/wvankuipers/webpack-test

It seems to be specific to Backbone.Marionette in combination with the babel-minify-webpack-plugin package.

wvankuipers commented 7 years ago

I did some more research and it seems to be coming down to this line in the Backbone.Marionette library:

typeof define === 'function' && define.amd ? define(['backbone', 'underscore', 'backbone.radio'], factory) :

And then specificly

define(['backbone', 'underscore', 'backbone.radio'], factory)

Even removing the rest of that file's content and leaving only this part there will cause Webpack to fail with the error above... Removing this line and Webpack wil succeed.

wvankuipers commented 7 years ago

A (temporary) workaround for this issue is to add

sourceMap: null

To the configuration of the babel-minify-webpack-plugin package.

dancollingridge commented 7 years ago

Same issue here. I had to force install version 1.0.1 (rather than letting webpack pull in its own version) to get my project to build:

     "webpack": "^2.2.1",
+    "webpack-sources": "1.0.1",
     "webpack-bundle-analyzer": "^2.2.1",
     "webpack-dev-middleware": "^1.10.0",
     "webpack-hot-middleware": "^2.16.1",
michael-ciniawsky commented 7 years ago

@dancollingridge Could you provide Error logs and a bit of relevant context about your project ?

fkarczeski commented 7 years ago

I also had the same issue.

Error: 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] (webpack-repo\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:276:15)
at SourceMapGenerator_addMapping [as addMapping] (webpack-repo\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:110:12)
at webpack-repo\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:72:17
at Array.forEach (native)
at SourceMapConsumer_eachMapping [as eachMapping] (webpack-repo\node_modules\webpack-sources\node_modules\source-map\lib\source-map-consumer.js:157:14)
at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (webpack-repo\node_modules\webpack-sources\node_modules\source-map\lib\source-map-generator.js:48:24)
at SourceMapSource.node (webpack-repo\node_modules\webpack-sources\lib\SourceMapSource.js:32:35)
at SourceMapSource.proto.sourceAndMap (webpack-repo\node_modules\webpack-sources\lib\SourceAndMapMixin.js:30:18)
at getTaskForFile (webpack-repo\node_modules\webpack\lib\SourceMapDevToolPlugin.js:33:30)
at chunk.files.forEach.file (webpack-repo\node_modules\webpack\lib\SourceMapDevToolPlugin.js:91:21)
at Array.forEach (native)
at webpack-repo\node_modules\webpack\lib\SourceMapDevToolPlugin.js:89:18
at Array.forEach (native)
at Compilation.<anonymous> (webpack-repo\node_modules\webpack\lib\SourceMapDevToolPlugin.js:88:12)
at Compilation.applyPlugins1 (webpack-repo\node_modules\tapable\lib\Tapable.js:75:14)
at self.applyPluginsAsync.err (webpack-repo\node_modules\webpack\lib\Compilation.js:644:11)
at next (webpack-repo\node_modules\tapable\lib\Tapable.js:202:11)
at Compilation.<anonymous> (webpack-repo\node_modules\babili-webpack-plugin\lib\index.js:106:11)
at next (webpack-repo\node_modules\tapable\lib\Tapable.js:204:14)
at webpack-repo\node_modules\last-call-webpack-plugin\index.js:156:7
at process._tickCallback (internal/process/next_tick.js:109:7)
michael-ciniawsky commented 7 years ago

@fkarczeski Could you try without the babili-webpack-plugin please ?

@dancollingridge Are you also using babili-webpack-plugin for minification?

dancollingridge commented 7 years ago

Exact same trace as posted above.

My app is a Vue.js app.

package.json target is:

"build": "node build/build.js",

npm run build produces:

$: npm run build
npm info it worked if it ends with ok
npm info using npm@4.2.0
npm info using node@v7.9.0
npm info lifecycle lift@0.1.0~prebuild: lift@0.1.0
npm info lifecycle lift@0.1.0~build: lift@0.1.0

> lift@0.1.0 build /var/www/lift
> node build/build.js

⠹ building for production.../var/www/lift/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:276
        throw new Error(
        ^

Error: original.line and original.column are not numbers -- you probably mea.............
dancollingridge commented 7 years ago

Yes, I am using babili-webpack-plugin.

dancollingridge commented 7 years ago

In build/webpack.prod.conf.js:

var BabiliPlugin = require("babili-webpack-plugin")
//.......a bunch of other code.......
new BabiliPlugin({}, {}),
//.......a bunch of other code.......
michael-ciniawsky commented 7 years ago

@dancollingridge Does the build succeed without babili-webpack-plugin ?

new BabiliPlugin({}*, {}*),

is this* 'pseudo' or did you try without any options ?

michael-ciniawsky commented 7 years ago

Which version of babili-webpack-plugin ?

⚠️ It was recently renamed to babel-minify-webpack-plugin which includes a newer version of babel-minify (former babili)

michael-ciniawsky commented 7 years ago

cc @boopathi

fkarczeski commented 7 years ago

@michael-ciniawsky , not calling BabiliPlugin works (as expected).

This is my current set up that fails: new BabiliPlugin({}, require("babel-preset-minify"))

Calling with no options also fails for me with the same error: new BabiliPlugin({}, {})

babili-webpack-plugin "version": "0.1.2"

michael-ciniawsky commented 7 years ago

Yep, the plugin uses webpack-sources directly to update the assets

dancollingridge commented 7 years ago

If I disable babili-webpack-plugin in webpack.config the build works.

If I replace babili-webpack-plugin with babel-minify-webpack-plugin I get the same error as before.

wvankuipers commented 7 years ago

I also tried both babili-weback plugin and babel-minify-webpack-plugin and found them both giving the same error. As proposed by @mattdsteele I created a issue in the source-map project as this seems not to be purely related to the webpack-sources package.

breadadams commented 7 years ago

I'm using babel-minify-webpack-plugin@0.2.0, forcing webpack-sources to 1.0.1 in package.json as @dancollingridge suggested appears to fix it for now (as many more have said here https://github.com/webpack/webpack/issues/5931)

jussikinnula commented 6 years ago

I'm also interested in this.

nealoke commented 6 years ago

Just wanted to chip in and say that in my case it doesn't matter if i use the BabiliPlugin() or not, as long as I don't have the "webpack-sources": "1.0.1" installed it always fails.

Also wanted to provide you with my files used:

Cases

catamphetamine commented 6 years ago

Replacing require('babili-weback-plugin') with require('uglifyjs-webpack-plugin') works

alex-kinokon commented 6 years ago

@catamphetamine It works because then you’d be using an entirely different thing.

anthonator commented 6 years ago

Has anyone tried source-map 0.7.0?

SEAPUNK commented 6 years ago

So is the solution here to just not use the babili plugin, or is there a version we can bump to get rid of this error?

scottohara commented 6 years ago

If you can wait a couple of weeks and assuming you will be able to upgrade immediately; webpack@4.x will come with support for UglifyJS2 (expected on or around Feb 24).

I have a number of projects using babel-minify-webpack-plugin that have been affected by this issue since it first started on 4 November (when webpack-sources@1.0.2 was released), and I've been patiently waiting for a fix now for three months. Another couple of weeks (for me) isn't going to hurt. The only reason I was using babel-minify was for it's support for >ES5, and since UglifyJS2 will now have this, there's little reason for me to stick with the former.

It seems like nobody really wants to take ownership of the problem.

Despite numerous examples showing how to reproduce the problem, some of the early comments in the issue over in mozilla/source-map (https://github.com/mozilla/source-map/issues/304) seem to suggest that they think their library is working as intended, and that any 'fix' belongs elsewhere.

In webpack/webpack-sources (here), the problem clearly started when moving to source-map@0.6.0; and comments in this thread suggest that they believe the problem squarely lies with source-map.

SEAPUNK commented 6 years ago

@scottohara To be honest, I'm not really interested in UglifyJS2; I chose babel-minify, and I want to stick with it. Switching back to UJS2 won't solve this issue.

In the meantime, the workaround I implemented was forcing webpack to switch to webpack-sources@1.0.1.

thuringia commented 6 years ago

@anthonator source-map@7does not work at least in my limited testing. It's trowing a TypeError now in webpack's source-map devtool

TypeError: aSourceMapConsumer.eachMapping is not a function [0] at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (/Users/rwa/Developer/hotel/node_modules/source-map/lib/source-node.js:86:24) [0] at SourceMapSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/SourceMapSource.js:39:21) [0] at ReplaceSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ReplaceSource.js:70:30) [0] at CachedSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/CachedSource.js:18:24) [0] at /Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:37:50 [0] at Array.map () [0] at ConcatSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:36:63) [0] at /Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:37:50 [0] at Array.map () [0] at ConcatSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:36:63) [0] at /Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:37:50 [0] at Array.map () [0] at ConcatSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:36:63) [0] at /Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:37:50 [0] at Array.map () [0] at ConcatSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:36:63) [0] at /Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:37:50 [0] at Array.map () [0] at ConcatSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:36:63) [0] at /Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:37:50 [0] at Array.map () [0] at ConcatSource.node (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/ConcatSource.js:36:63) [0] at ConcatSource.proto.sourceAndMap (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/SourceAndMapMixin.js:30:18) [0] at CachedSource.sourceAndMap (/Users/rwa/Developer/hotel/node_modules/webpack-sources/lib/CachedSource.js:56:31) [0] at getTaskForFile (/Users/rwa/Developer/hotel/node_modules/webpack/lib/SourceMapDevToolPlugin.js:34:30) [0] at files.forEach (/Users/rwa/Developer/hotel/node_modules/webpack/lib/SourceMapDevToolPlugin.js:127:20) [0] at Array.forEach () [0] at compilation.hooks.afterOptimizeChunkAssets.tap (/Users/rwa/Developer/hotel/node_modules/webpack/lib/SourceMapDevToolPlugin.js:121:12) [0] at SyncHook.eval (eval at create (/Users/rwa/Developer/hotel/node_modules/tapable/lib/HookCodeFactory.js:17:12), :7:1) [0] at SyncHook.lazyCompileHook [as _call] (/Users/rwa/Developer/hotel/node_modules/tapable/lib/Hook.js:35:21)

wvankuipers commented 6 years ago

Seems to be an issue with https://github.com/webpack-contrib/babel-minify-webpack-plugin/issues/68 but not sure if it is originated in this project or babel-minify

alexander-akait commented 6 years ago

We use latest source-map version with compatibility node@6 (https://github.com/webpack/webpack-sources/blob/master/package.json#L19), will be updated after we drop support node@6, plugins can use own version, feel free create issue where we use old version