Closed mcm-ham closed 3 years ago
Seeing similar error with ember-cli 0.1.15.
We're having the same issue over here on ember-cli 0.2.0 and ember-cli-uglify 1.0.1. Tested multiple node/io.js versions. The issue only goes away if we disable minification entirely by setting EmberCLI's options.minifyJS.enabled=false
.
Is it just me or does it seem odd that the column is a negative number? (I'm running into this as well and trying to debug it.)
Seems like this always happens in vendor.js
when it gets minified. That seems to be put together with @ef4's https://github.com/ef4/broccoli-sourcemap-concat, which doesn't appear to be using the mozilla generator and is special cased for line-to-line mappings. Perhaps there is some other stuff going on here that Edward's generator isn't yet prepared to deal with?
It at least seems to always go through this codepath before blowing up to give the generated sourcemap. https://github.com/mishoo/UglifyJS2/blob/master/lib/sourcemap.js#L59
@SimonKaluza @matthiasleitner @mcm-ham Are any of you all using es5-shim? I think the \f (form feed) in the file may be throwing things off.
@fivetanley Yep, we're using es5-shim 4.1.0 from bower
It looks like all of a sudden the Ember.assert
stripping is happening after we've already generated the sourcemap, which throws is all off.
Does the ember-cli build pipeline have some sort of "run this last" declaration to avoid that kind of order constraint?
This is the problem: https://github.com/emberjs/data/issues/2871
Ember Data was the problem here. I hotfixed (removed the sourcemapping url) from the production files on the bower components repo.
Can everyone try:
bower cache clean
rm -rf bower_components
bower i
and report back?
I didn't realize the production files had source mapping urls. Sorry for breaking this everyone, we'll make sure we get it fixed for the next release of Ember Data. Thanks @ef4 for figuring it out!
Nice find @ef4 and nice fix @fivetanley! Thanks.
EDIT I was a bit hasty with this comment, I'm still getting that error. When I tested it late last night I hadn't actually remembered to turn my uglifyJS option back to true! :-/
@fivetanley I'm still seeing it in our project https://github.com/crossroads/app.goodcity, but works if I create a new project. Will try removing packages to see if there is some other package causing this.
@mcm-ham I am sorry to hear you are still having issues. I double checked just to make sure (i removed it on several versions) and it looks like beta.15 (the version in your project) should have it removed: https://github.com/components/ember-data/blob/1.0.0-beta.15/ember-data.prod.js#L12728
I'll keep checking back, sorry for the pain. :(
Thanks fivetanley. Actually I can reproduce this on a new project.
Brocfile.js:
var app = new EmberApp({
minifyCSS: {enabled:true},
minifyJS: {enabled:true}
});
ember build
I had followed the steps in https://github.com/ef4/broccoli-uglify-sourcemap/issues/1 when I tested a new project before and it works, but was actually doing this when testing our project since we created a staging environment.
@mcm-ham I was not able to reproduce with a new ember cli app. Maybe I missed a step... would you mind throwing up the repository on github so I can reference it? also the output of npm -v
bower -v
and ember -v
would be great.
@fivetanley sure, here's the repo: https://github.com/mcm-ham/ember-uglify-error-demo
embe-cli -v version: 0.2.0 node: 0.12.0 npm: 2.7.0
npm -v 2.5.1
bower -v 1.3.12
I opened an issue in https://github.com/ember-cli/ember-cli/issues/3527, but I'm open to moving the discussion here.
After pulling from the most recent ember-data bower package, I'm still experiencing this problem. Furthermore, I can also reproduce this issue using @mcm-ham's instructions above.
ember -v version: 0.2.0 node: 0.12.0 npm: 2.7.0
npm -v 2.5.1
bower -v 1.3.12
I'm also seeing this error when trying to build for production, and I've already updated to the latest commit of ember-data. Removing packages just moves the error around, and now the error is supposedly coming from ember-cli itself:
Build failed.
Invalid mapping: {"generated":{"line":70087,"column":-50},"source":"vendor/ember-cli/vendor-suffix.js","original":{"line":1,"column":0},"name":null}
Error: Invalid mapping: {"generated":{"line":70087,"column":-50},"source":"vendor/ember-cli/vendor-suffix.js","original":{"line":1,"column":0},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:272:15)
at SourceMapGenerator_addMapping [as addMapping] (/Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:102:12)
at /Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:74:19
at Array.forEach (native)
at SourceMapConsumer_eachMapping [as eachMapping] (/Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-consumer.js:473:10)
at Function.SourceMapGenerator_fromSourceMap (/Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:50:26)
at Object.SourceMap (/Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/lib/sourcemap.js:59:52)
at Object.exports.minify (/Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:112:38)
at UglifyWriter.processFile (/Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/index.js:98:25)
at /Users/jlabarba/PLOS/lemur-collections/frontend/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/index.js:46:14
FWIW, the ember-uglify-error-demo does reproduce the error for me as well.
$ ember -v
version: 0.2.0
node: 0.12.0
npm: 2.7.0
$ bower -v
1.3.12
$ npm -v
2.7.1
@dweebit It's working for me for production builds, it's just non-production builds it's not working for me. So by updating to the latest version of ember-data I take it you mean you ran bower cache clean
before bower install
? For non-production builds, e.g. staging, I'm currently using this work-around:
Brocfile.js:
var app = new EmberApp({
sourcemaps: ['js']
});
staging=true ember build --environment=production
And then in code using this to check if I'm actually in staging not production:
process.env.staging === 'true'
I'm also able to reproduce this error using the demo repo, with a an npm and bower install right after cleaning the cache. Are there other libraries with invalid source map URLs?
@mcm-ham actually, the bower cache clean
did it for me! woot! Sorry for the false alarm.
I am having the same issue for non-production builds with the following settings in Brocfile.js.
minifyCSS: {
enabled: true,
},
minifyJS: {
enabled: true
},
My environment information are below.
ember v
version: 0.2.1
node: 0.12.0
npm: 2.7.3
As long as I disable minifyCSS
and minifyJS
, I don't get the error for non-production builds.
Is this still an issue here?
Any news on this issue? I'm getting the same error but it lists Modernizr as the culprit...
Invalid mapping: {"generated":{"line":74625,"column":-50},"source":"bower_components/modernizr/modernizr.js","original":{"line":1,"column":0},"name":null}
Error: Invalid mapping: {"generated":{"line":74625,"column":-50},"source":"bower_components/modernizr/modernizr.js","original":{"line":1,"column":0},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:272:15)
at SourceMapGenerator_addMapping [as addMapping] (/Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:102:12)
at /Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:74:19
at Array.forEach (native)
at SourceMapConsumer_eachMapping [as eachMapping] (/Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-consumer.js:473:10)
at Function.SourceMapGenerator_fromSourceMap (/Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js:50:26)
at Object.SourceMap (/Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/lib/sourcemap.js:59:52)
at Object.exports.minify (/Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:113:38)
at UglifyWriter.processFile (/Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/index.js:98:25)
at /Users/eli/showbie/web/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/index.js:46:14
For me, this happens in any environment that has sourcemaps and minification enabled. So disabling the sourcemaps gets rid of the error...
sourcemaps: {
enabled: false
}
@elidupuis Good call on disabling sourcemaps, that clears up the error for me as well and will work as a band aid for my production environment. That said, using both soucemaps and minification also still crashes, in my case listing ember-cli-cordova
as the culprit.
Is there a reason that sourcemap + minification is inherently incompatible? Facing this problem too, disabling minification for now as debugging is more important to us than a small asset bundle, but its hardly ideal.
Is there a reason that sourcemap + minification is inherently incompatible?
No, they actually compliment each other. Sourcemapping lets you debug through the minification.
Uglify is picky about getting a valid input sourcemap. If any of your dependencies ship with a broken one you will hit this problem.
Experimenting the same problem here with velocity js (coming from liquidfire).
See also ember-cli/ember-cli#3527 and ember-cli/ember-cli#3657
@cibernox interestingly, d3.js
is coming from ember-nf-graph for us.
@mcm-ham it works for me in production as well. I tried turning it on in a staging build and it failed there.
Any progress on this? Seems sourcemaps + ember-cli-uglify are completely broken...
Just wanted to chime in and say it's still happening
for me it only works only when I disable minification :/
(There's no point of generating sourcemaps if your JS is not minified!)
Thats not true, there are all sorts of other possible processes between source code and output JS.
Modules, JSX, CoffeeScript... Though in the case of ember-cli only modules are relevant
On Fri, 7 Aug 2015 at 10:44 Johnny Shields notifications@github.com wrote:
(There's no point of generating sourcemaps if your JS is not minified!)
— Reply to this email directly or view it on GitHub https://github.com/ember-cli/ember-cli-uglify/issues/4#issuecomment-128658454 .
I tracked this down to a third party package (in this case showdown) using:
//# sourceMappingURL=showdown.js.map
comments.
Is there a way we could strip/ignore these automatically? Or should we be going back to the third party packages and asking them to exclude them from their dist
builds (in showdown's case the src
folder is empty for the bower package, so I'm not sure what the point of the source map is?)
Is there any movement on this issue? Source-maps are fundamentally broken in the Ember ecosystem it seems.
Lots of people use sourcemaps fine, with minification. But it breaks if one of your deps is shipping a bad sourcemaps.
Is it possible to ignore and warn the bad sourcemap for faulty dep, rather than causing the entire build to fail?
Using ember-cli 1.13.8 I run ember new temp
then edit ember-cli-build enabling sourcemaps and minification. My plan was to add dependencies to package.json from my actual project to this temporary project until sourcemaps with minification builds failed, identifying what dependencie were causing the issue. Unfortunately the build fails with a fresh project.
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
sourcemaps: {
enabled: true,
extensions: ['js']
},
minifyCSS: { enabled: true },
minifyJS: { enabled: true },
});
return app.toTree();
};
Then I run ember build
and get an invalid error mapping.
version: 1.13.8
Build failed.
File: assets/vendor.js
Invalid mapping: {"generated":{"line":86654,"column":-50},"source":"ember-cli-app-version/components/app-version.js","original":{"line":1,"column":0},"name":null}
$ ember -v
version: 1.13.8
node: 4.2.1
npm: 2.13.4
os: linux x64
$ bower -v
1.6.5
$ npm -v
2.14.7
@ef4 I'm not trying to pile on here, but this seems to be getting totally dismissed. This is definitely not a bad 3rd party dep problem. This is happening with brand new ember-cli projects. Here's the only file change I made in a brand new project:
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
minifyJS: {
enabled: true // Test out minification with source mapping
}
});
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
return app.toTree();
};
And here is the full output from my console for the steps:
15:54:41 kjones /Users/kjones/code/js ()
$ ember new test-minify
Future versions of Ember CLI will not support v4.2.1. Please update to Node 0.12 or io.js.
version: 1.13.8
installing app
create .bowerrc
create .editorconfig
create .ember-cli
create .jshintrc
create .travis.yml
create .watchmanconfig
create README.md
create app/app.js
create app/components/.gitkeep
create app/controllers/.gitkeep
create app/helpers/.gitkeep
create app/index.html
create app/models/.gitkeep
create app/router.js
create app/routes/.gitkeep
create app/styles/app.css
create app/templates/application.hbs
create app/templates/components/.gitkeep
create bower.json
create config/environment.js
create ember-cli-build.js
create .gitignore
create package.json
create public/crossdomain.xml
create public/robots.txt
create testem.json
create tests/.jshintrc
create tests/helpers/resolver.js
create tests/helpers/start-app.js
create tests/index.html
create tests/test-helper.js
create tests/unit/.gitkeep
create vendor/.gitkeep
Installed packages for tooling via npm.
Installed browser packages via Bower.
Successfully initialized git.
15:56:38 kjones /Users/kjones/code/js ()
$ cd test-minify/
15:57:13 kjones /Users/kjones/code/js/test-minify (master)
$ vim ember-cli-build.js
15:58:38 kjones /Users/kjones/code/js/test-minify (master)
$ ember serve
Future versions of Ember CLI will not support v4.2.1. Please update to Node 0.12 or io.js.
version: 1.13.8
Livereload server on http://localhost:49152
Serving on http://localhost:4200/
File: assets/vendor.js
Invalid mapping: {"generated":{"line":86654,"column":-50},"source":"ember-cli-app-version/components/app-version.js","original":{"line":1,"column":0},"name":null}
Error: Invalid mapping: {"generated":{"line":86654,"column":-50},"source":"ember-cli-app-version/components/app-version.js","original":{"line":1,"column":0},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map-generator.js:271:15)
at SourceMapGenerator_addMapping [as addMapping] (/Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map-generator.js:101:14)
at /Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map-generator.js:72:19
at Array.forEach (native)
at SourceMapConsumer_eachMapping [as eachMapping] (/Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map-consumer.js:155:16)
at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (/Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/node_modules/source-map/lib/source-map-generator.js:48:26)
at Object.SourceMap (eval at <anonymous> (/Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:7575:52)
at Object.exports.minify (/Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:102:38)
at UglifyWriter.processFile (/Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/index.js:99:27)
at /Users/kjones/code/js/test-minify/node_modules/ember-cli-uglify/node_modules/broccoli-uglify-sourcemap/index.js:46:14
Content Security Policy violation: {"csp-report":{"document-uri":"http://localhost:4200/","referrer":"http://localhost:4200/","violated-directive":"style-src 'self'","effective-directive":"style-src","original-policy":"default-src 'none'; script-src 'self' 'unsafe-eval' localhost:49152 0.0.0.0:49152; font-src 'self'; connect-src 'self' ws://localhost:49152 ws://0.0.0.0:49152 http://0.0.0.0:4200/csp-report; img-src 'self'; style-src 'self'; media-src 'self'; report-uri http://0.0.0.0:4200/csp-report;","blocked-uri":"","status-code":500}}
^C16:06:09 kjones /Users/kjones/code/js/test-minify (master)
$ ember --version
Future versions of Ember CLI will not support v4.2.1. Please update to Node 0.12 or io.js.
version: 1.13.8
node: 4.2.1
npm: 2.13.4
os: darwin x64
I can put this into a repo and share it, but that seems like overkill for an almost untouched base project.
For anyone looking for a hacky workaround, I've whipped something up that helps. I grep
bower_components/
for sourceMappingURL
and them remove it. Wala!
grep -lr --include=*.js sourceMappingURL bower_components/ | xargs gsed -i 's/sourceMappingURL//g'
I've added that to my Makefile
and run it before ember build -prod
and everything appears to be working fine.
@matthiasleitner thx for workaround )
:+1: for hack! :)
Sorry to those who keep running into this. I don't think this should be happening anymore on recent versions of Ember Data. I was responsible for generating the invalid sourcemaps. I think we ended up just removing the sourcemap comment in the bower releases.
As of 2.3.0 Ember Data will be a full fledged Ember CLI addon, but if I missed your release of Ember Data let me know and I'll see what we can do.
This should definitely not be happening for new apps so ping me if it is.
I was having issues with a number of addons that we're bringing in bower libraries that had their own sourmap comments, not just ember-data
On December 18, 2015 at 2:52:36 PM, Stanley Stuart (notifications@github.com) wrote: Sorry to those who keep running into this. I don't think this should be happening anymore on recent versions of Ember Data. I was responsible for generating the invalid sourcemaps. I think we ended up just removing the sourcemap comment in the bower releases.
As of 2.3.0 Ember Data will be a full fledged Ember CLI addon, but if I missed your release of Ember Data let me know and I'll see what we can do.
This should definitely not be happening for new apps so ping me if it is.
— Reply to this email directly or view it on GitHub.
I was having issues with a number of addons that we're bringing in bower libraries that had their own sourmap comments, not just ember-data
can you provide a list?
Tracked this down to ember-cli-es5-shim
in our project, specifically bower_components/es5-shim/es5-shim.min.js
I'm still having this issue
➜ powerseller git:(master) ember build -prod
version: 2.2.0-beta.6
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
Build failed.
File: assets/vendor.js
Invalid mapping: {"generated":{"line":90502,"column":-15473},"source":"ember-ajax/errors.js","original":{"line":1,"column":0},"name":null}
Error: Invalid mapping: {"generated":{"line":90502,"column":-15473},"source":"ember-ajax/errors.js","original":{"line":1,"column":0},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/source-map/lib/source-map-generator.js:271:15)
at SourceMapGenerator_addMapping [as addMapping] (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/source-map/lib/source-map-generator.js:101:14)
at /Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/source-map/lib/source-map-generator.js:72:19
at Array.forEach (native)
at SourceMapConsumer_eachMapping [as eachMapping] (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/source-map/lib/source-map-consumer.js:155:16)
at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/source-map/lib/source-map-generator.js:48:26)
at Object.SourceMap (eval at <anonymous> (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:7575:52)
at Object.exports.minify (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/broccoli-uglify-sourcemap/node_modules/uglify-js/tools/node.js:102:38)
at UglifyWriter.processFile (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/broccoli-uglify-sourcemap/index.js:118:27)
at /Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/broccoli-uglify-sourcemap/index.js:62:16
at Array.forEach (native)
at /Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/broccoli-uglify-sourcemap/index.js:52:21
at lib$rsvp$$internal$$tryCatch (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/rsvp/dist/rsvp.js:493:16)
at lib$rsvp$$internal$$invokeCallback (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/rsvp/dist/rsvp.js:505:17)
at lib$rsvp$$internal$$publish (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/rsvp/dist/rsvp.js:476:11)
at lib$rsvp$asap$$flush (/Users/LABS-WANGZ-MAC/Desktop/powerseller/node_modules/rsvp/dist/rsvp.js:1198:9)
at nextTickCallbackWith0Args (node.js:452:9)
at process._tickCallback (node.js:381:13)
➜ powerseller git:(master) node -v
v5.4.1
➜ powerseller git:(master) npm -v
3.3.12
➜ powerseller git:(master)
@Cryrivers this might be from another package. I would check all your bower components...
With ember-cli 0.2.0, node 0.12 and ember-cli-uglify 1.0.1 I'm getting this error:
If I remove select2 I get the same error with the next vendor package I have included so don't think it's specific to select2.