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

error with sourcemaps #68

Open
dancespiele opened this Issue Nov 9, 2017 · 36 comments

Comments

Projects
None yet
@dancespiele
Copy link

dancespiele commented Nov 9, 2017

I reproduce this issue when I use source maps with this plugin.
My config file:

const path = require('path')
const webpack = require("webpack");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MinifyPlugin = require("babel-minify-webpack-plugin");

module.exports = {
	entry: path.resolve(__dirname, './app/component/index'),
    devtool: 'source-map',
	output: {
		path: path.resolve(__dirname, './dist'),
		filename: 'app.bundle.js'
	},

	resolve: {
		extensions: ['.ts', '.tsx', '.js', '.jsx']
	},

	module: {
		rules: [{
			test: /\.tsx?$/,
			exclude: /node_modules/,
			loaders: ['ts-loader']
		}, {
			test: /\.css$/,
			include: /node_modules/,
			loaders: ['style-loader', 'css-loader']
		}, {
			test: /\.scss$/,
			use: [{
				loader: "style-loader"
			}, {
				loader: "css-loader"
			}, {
				loader: "sass-loader"
			}]
		}, {
			test: /\.(eot|svg|ttf|woff|woff2)$/,
			loaders: ['file-loader?name=fonts/[name].[ext]']
        }]
    },
    
    plugins: [
        new MinifyPlugin()
    ]
}

The error which I get is this:

/home/razorpack/develop/pyrite-prism/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] (/home/razorpack/develop/pyrite-prism/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:276:15)
    at SourceMapGenerator_addMapping [as addMapping] (/home/razorpack/develop/pyrite-prism/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:110:12)
    at /home/razorpack/develop/pyrite-prism/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] (/home/razorpack/develop/pyrite-prism/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:157:14)
    at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (/home/razorpack/develop/pyrite-prism/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:48:24)
    at SourceMapSource.node (/home/razorpack/develop/pyrite-prism/node_modules/webpack-sources/lib/SourceMapSource.js:32:35)
    at SourceMapSource.proto.sourceAndMap (/home/razorpack/develop/pyrite-prism/node_modules/webpack-sources/lib/SourceAndMapMixin.js:30:18)
    at getTaskForFile (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/SourceMapDevToolPlugin.js:33:30)
    at chunk.files.forEach.file (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/SourceMapDevToolPlugin.js:91:21)
    at Array.forEach (<anonymous>)
    at /home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/SourceMapDevToolPlugin.js:89:18
    at Array.forEach (<anonymous>)
    at Compilation.<anonymous> (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/SourceMapDevToolPlugin.js:88:12)
    at Compilation.applyPlugins1 (/home/razorpack/develop/pyrite-prism/node_modules/tapable/lib/Tapable.js:75:14)
    at self.applyPluginsAsync.err (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/Compilation.js:670:11)
    at next (/home/razorpack/develop/pyrite-prism/node_modules/tapable/lib/Tapable.js:202:11)
    at Compilation.<anonymous> (/home/razorpack/develop/pyrite-prism/node_modules/babel-minify-webpack-plugin/dist/index.js:119:11)
    at Compilation.applyPluginsAsyncSeries (/home/razorpack/develop/pyrite-prism/node_modules/tapable/lib/Tapable.js:206:13)
    at self.applyPluginsAsync.err (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/Compilation.js:666:10)
    at Compilation.applyPluginsAsyncSeries (/home/razorpack/develop/pyrite-prism/node_modules/tapable/lib/Tapable.js:195:46)
    at sealPart2 (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/Compilation.js:662:9)
    at Compilation.applyPluginsAsyncSeries (/home/razorpack/develop/pyrite-prism/node_modules/tapable/lib/Tapable.js:195:46)
    at Compilation.seal (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/Compilation.js:605:8)
    at applyPluginsParallel.err (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/Compiler.js:508:17)
    at /home/razorpack/develop/pyrite-prism/node_modules/tapable/lib/Tapable.js:289:11
    at _addModuleChain (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/Compilation.js:507:11)
    at processModuleDependencies.err (/home/razorpack/develop/pyrite-prism/node_modules/webpack/lib/Compilation.js:477:14)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pyrite-bootstrap@0.0.1 production: `webpack --config ./webpack.production.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pyrite-bootstrap@0.0.1 production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/razorpack/.npm/_logs/2017-11-09T19_15_16_251Z-debug.log

When I use the source maps without this plugin it works fine.
The version plugin is: 0.2.0

@michael-ciniawsky

This comment has been minimized.

Copy link
Member

michael-ciniawsky commented Nov 10, 2017

Could you try to provide a small repo with a file/module where this error occurs ? I'm currently debugging this and a failing example would be quite helpful :)

@dancespiele

This comment has been minimized.

Copy link

dancespiele commented Nov 10, 2017

Sure @michael-ciniawsky, this is the repository https://github.com/pyrite-components/pyrite-prism . You have to install as global nodemon and typescript. To reproduce the fail you need to execute npm run production

@simonbuchan

This comment has been minimized.

Copy link

simonbuchan commented Nov 15, 2017

In particular, I found cheap-* source maps work, e.g. module-source-map dies, while cheap-module-source-map does not.

@ingro

This comment has been minimized.

Copy link

ingro commented Dec 4, 2017

Got the same problem, using cheap-source-map instead of source-map doesn't throw error though.

@timwis

This comment has been minimized.

Copy link

timwis commented Dec 5, 2017

Just want to chime in that this is happening to me too. Ref webpack/webpack#5931

For those unfamiliar with cheap-source-map, here's some docs: https://webpack.js.org/configuration/devtool/

@eliperelman

This comment has been minimized.

Copy link

eliperelman commented Dec 8, 2017

Running git bisect on this turns up the following commit:

❯ git bisect good
d0a724cec766ea5fbea9ecc514d38f7fd2ee3735 is the first bad commit
commit d0a724cec766ea5fbea9ecc514d38f7fd2ee3735
Author: Joshua Wiens <wiens.joshua@gmail.com>
Date:   Sat Aug 12 02:50:01 2017 -0500

    refactor: Apply webpack-defaults (#51)

    * refactor: Init webpack-defaults
    * style: Update for defaults
    * chore: Remove legacy babel env setting
    * chore: Update repo & bugs in pacakge.json
    * test: Fix source map test assertion syntax

    BREAKING CHANGE: Enforces `engines` of `"node": ">=4.3.0 < 5.0.0 || >= 5.10`
    BREAKING CHANGE: Enforces `peerDependency` of `"webpack": "^2.0.0 || ^3.0.0`

:100644 100644 354caa95dfed982fff17dafbe378e1b253fdbdba e7e4dbd99b91e6c699aeecd4e21b72594c00093e M	.babelrc
:100644 100644 1a096400cea55f9c0bfd7abb3da880c31ffce53d 1f899991b1335c3b8fc09a137fa5e6269bb2b65e M	.editorconfig
:000000 100644 0000000000000000000000000000000000000000 b2d59d1f7578b05e96f3b3f8a7d5039df3d06fb6 A	.eslintignore
:000000 100644 0000000000000000000000000000000000000000 4016c3eed18c749c8d968ccf89ce374bbb611842 A	.eslintrc
:100644 000000 d98f68986934414fd629c5a9774bcb810a4bf237 0000000000000000000000000000000000000000 D	.eslintrc.js
:000000 100644 0000000000000000000000000000000000000000 b07091b9b12ca11a84f562f56cdb4156712280be A	.gitattributes
:000000 040000 0000000000000000000000000000000000000000 7094ba2f4446b63099d07d17b7663d5412d01a74 A	.github
:100644 100644 8a05de541c440248984dc2b58407e2a327875b31 de347064f4986dab4d1133dc79dde317f7d48c7b M	.gitignore
:100644 100644 ddccd23750a34fbd08773ef6a2d7615c6137835c 76b149227e1523aaecc5a129652073d922571d6d M	.travis.yml
:000000 100644 0000000000000000000000000000000000000000 95fd7360e907a3797f16dcef7b00d4b138d4ca06 A	CHANGELOG.md
:000000 100644 0000000000000000000000000000000000000000 aa4f18a5043eac562724cbfd7f2ec1f5b7764b77 A	appveyor.yml
:000000 100644 0000000000000000000000000000000000000000 0dde8ba5af5e47cfa7fdf40e444f986ac3d6db2c A	package-lock.json
:100644 100644 cce2507527c11f4a2e0f1e4e44d1035dae31da0c 9bb3ec1bb62095452e50c3e4379092b566a6fa4b M	package.json
:040000 040000 908bc17c9eaea633e6821e219a4ca213d945cdd4 e3c1dacbbd18feab5b4451ac516841134d14d79f M	src
:040000 040000 5dc5817b66f78e6ea66ccd3e51410b03f1e1753e 82c3316b8e07d066761dd89486d54ba1ef656838 M	test
:100644 000000 b36b79094e0678df41773b4ed923b7c561459e44 0000000000000000000000000000000000000000 D	yarn.lock
@bradchoate

This comment has been minimized.

Copy link

bradchoate commented Dec 12, 2017

Also having this problem with the 'source-map' option.

@nealoke

This comment has been minimized.

Copy link

nealoke commented Dec 16, 2017

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

  • npm run server -> no error
  • npm run server:test -> error (if webpack-sources@1.0.1 is not explicitly installed)
  • npm run build:prod -> no error
@Alfredo-Delgado

This comment has been minimized.

Copy link

Alfredo-Delgado commented Dec 18, 2017

I'm running into the same problem. I worked around it by pinning babili-webpack-plugin to 0.1.1.

cf. webpack/webpack#5931 (comment)

@saiichihashimoto

This comment has been minimized.

Copy link

saiichihashimoto commented Jan 4, 2018

So what's going on here? It seems like a breaking commit has been identified and that, most of the time, cheap-* avoids the problem while others don't. Do we need more repro examples?

@simonbuchan

This comment has been minimized.

Copy link

simonbuchan commented Jan 4, 2018

I'd guess cheap-* "fixing" it is since IIRC that disables minification source mapping (not much point mapping line-by-line if you only output one line!), but that doesn't narrow it down much. Seems there are plenty of references to this, so probably plenty of repro cases, just needs someone to spend the time on it.

@arbaaz

This comment has been minimized.

Copy link

arbaaz commented Jan 4, 2018

I'm also facing this issue.

@evilebottnawi

This comment has been minimized.

Copy link
Member

evilebottnawi commented Feb 2, 2018

Problem still exists? If yes please create minimum reproducible test repo. Thanks!

@arbaaz

This comment has been minimized.

Copy link

arbaaz commented Feb 2, 2018

I commented out BabiliPlugin and it was working.

// new BabiliPlugin()
@evilebottnawi

This comment has been minimized.

Copy link
Member

evilebottnawi commented Feb 2, 2018

@arbaaz Incredible solution :trollface:

@tarjei

This comment has been minimized.

Copy link

tarjei commented Feb 2, 2018

I feel a bit bad about saying this, but I changed to Uglify-es and got very good results both wrt to compilation speed and sourcemaps.

@evilebottnawi

This comment has been minimized.

Copy link
Member

evilebottnawi commented Feb 2, 2018

@tarjei i near future i implement cache and parallels, first we need fix bugs

@tarjei

This comment has been minimized.

Copy link

tarjei commented Feb 2, 2018

@ghost

This comment has been minimized.

Copy link

ghost commented Feb 5, 2018

@evilebottnawi
I have the similiar problem, and here is demo.

@Fzzr

This comment has been minimized.

Copy link

Fzzr commented Feb 7, 2018

I can reproduce the above as well. I am working around it by adding an explicit dependency on "webpack-sources": "1.0.1". Before I did this was using "webpack-sources": "1.1.0" in the generated package-lock.json.

My config file is virtually identical to the one given in the first comment.
node: v8.9.4
npm: v5.6.0

@ghost

This comment has been minimized.

Copy link

ghost commented Feb 10, 2018

0.3.0

Problem is not solved.

@Donskelle

This comment has been minimized.

Copy link

Donskelle commented Feb 13, 2018

Having same issue

@blittle

This comment has been minimized.

Copy link

blittle commented Feb 14, 2018

I was also able to work around the problem by forcing webpack-sources from 1.1.0 to 1.0.1. Thank you @Fzzr

@evilebottnawi

This comment has been minimized.

Copy link
Member

evilebottnawi commented Feb 14, 2018

Somebody other can confirm what upgrade webpack-source solve problem?

@ojab

This comment has been minimized.

Copy link

ojab commented Feb 14, 2018

AFAIU 1.1.0 is the last version for webpack-sources, the issue is reproducible with it.

@damianobarbati

This comment has been minimized.

Copy link

damianobarbati commented Feb 25, 2018

@evilebottnawi I tried both webpack-sources@1.1.0 and webpack-sources@1.0.1, still having:

 92% after chunk asset optimization SourceMapDevToolPlugin index.js generate SourceMap/Users/damz/Desktop/yarsk/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] (/Users/damz/Desktop/yarsk/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:276:15)

Temporarily disabling sourcemaps with config.devtool = false until solution is found.

@edmorley

This comment has been minimized.

Copy link

edmorley commented Mar 9, 2018

@d3viant0ne as the author of the regressing commit (see bisect in #68 (comment)) - I don't suppose you have any ideas as to what might have caused this? :-)

@KrofDrakula

This comment has been minimized.

Copy link

KrofDrakula commented Apr 6, 2018

Are there any updates on this to share? We're trying to use babel-minify as we're building for modern browsers, and we'd like to avoid having to go back to transpiling to ES5 in order to use Uglify in place of this plugin.

@ojab

This comment has been minimized.

Copy link

ojab commented Apr 6, 2018

uglify-es supports es6 syntax btw (but be aware of webpack-contrib/uglifyjs-webpack-plugin#262)

@evilebottnawi

This comment has been minimized.

Copy link
Member

evilebottnawi commented Apr 6, 2018

Right now i will develop minimizer-webpack-plugin (he has cache/parallels/etc nice features) and will have build-in uglify-es-minimizer-driver, uglify-js-minimizer-driver and babel-minify-minimizer-driver. Also he will support custom custom-minimizer-driver, example for css/images/etc. What is minimizer-driver? It is just one function. It is allow write custom minimizer drivers inside webpack config (example you want to remove newlines from some assets). If it meets the support of users, then maybe it will become a part of webpack. It is reduce config files and improve perf for any assets optimization 👍

Btw in near future i will implement minimize function to support using uglify-js 👍

@edmorley edmorley referenced this issue Apr 20, 2018

Merged

Update to webpack 4 #809

4 of 4 tasks complete

edmorley added a commit to neutrinojs/neutrino that referenced this issue Apr 24, 2018

Stop pinning webpack-sources to v1.0.1
It was required to work around a source map bug when using newer
`webpack-sources` with `babel-minify-webpack-plugin`:
webpack-contrib/babel-minify-webpack-plugin#68

However now that we're using `uglify-es` instead, we can stop pinning
the `webpack-sources` version and pick up some of the bug/perf fixes:
https://github.com/webpack/webpack-sources/releases

@schmidtk schmidtk referenced this issue May 21, 2018

Closed

WIP: Upgrade to webpack 4 #7740

2 of 4 tasks complete
@jbelien

This comment has been minimized.

Copy link

jbelien commented Sep 6, 2018

Any fix / workaround available for this issue ?


Temporarily disabling sourcemaps with config.devtool = false until solution is found.

I did the same but it's a bit unfortunate ...

jbelien added a commit to geo6/document-manager that referenced this issue Sep 6, 2018

Update webpack.config.js
Disable source-map for production due to issue with Babel plugin.
See webpack-contrib/babel-minify-webpack-plugin#68

RubenVerborgh added a commit to linkeddata/mashlib that referenced this issue Oct 17, 2018

@Pushplaybang

This comment has been minimized.

Copy link

Pushplaybang commented Nov 1, 2018

@jbelien - use uglify. thats what I'm doing.

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