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

Not working with source mapping #4

Closed
mcm-ham opened this issue Mar 12, 2015 · 56 comments
Closed

Not working with source mapping #4

mcm-ham opened this issue Mar 12, 2015 · 56 comments
Labels

Comments

@mcm-ham
Copy link

mcm-ham commented Mar 12, 2015

With ember-cli 0.2.0, node 0.12 and ember-cli-uglify 1.0.1 I'm getting this error:

Error: Invalid mapping: {"generated":{"line":75794,"column":-50},"source":"bower_components/select2/select2.js","original":{"line":1,"column":0},"name":null}

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.

mcm-ham added a commit to crossroads/app.goodcity that referenced this issue Mar 12, 2015
@matthiasleitner
Copy link

Seeing similar error with ember-cli 0.1.15.

@SimonKaluza
Copy link

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.

@fivetanley
Copy link

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.)

@fivetanley
Copy link

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?

@fivetanley
Copy link

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

@fivetanley
Copy link

@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.

@SimonKaluza
Copy link

@fivetanley Yep, we're using es5-shim 4.1.0 from bower

@ef4
Copy link

ef4 commented Mar 13, 2015

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.

@fivetanley
Copy link

Does the ember-cli build pipeline have some sort of "run this last" declaration to avoid that kind of order constraint?

@ef4
Copy link

ef4 commented Mar 13, 2015

This is the problem: emberjs/data#2871

@fivetanley
Copy link

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!

@SimonKaluza
Copy link

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! :-/

@mcm-ham
Copy link
Author

mcm-ham commented Mar 13, 2015

@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.

@fivetanley
Copy link

@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. :(

@mcm-ham
Copy link
Author

mcm-ham commented Mar 13, 2015

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 ember-cli/broccoli-terser-sourcemap#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.

@fivetanley
Copy link

@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.

@mcm-ham
Copy link
Author

mcm-ham commented Mar 16, 2015

@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

@MattNguyen
Copy link

I opened an issue in ember-cli/ember-cli#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

@JackLaBarba
Copy link

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

@JackLaBarba
Copy link

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

@mcm-ham
Copy link
Author

mcm-ham commented Mar 17, 2015

@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'

@indirect
Copy link

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?

@JackLaBarba
Copy link

@mcm-ham actually, the bower cache clean did it for me! woot! Sorry for the false alarm.

@vsymguysung
Copy link

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?

@johnnyshields
Copy link

Is there any movement on this issue? Source-maps are fundamentally broken in the Ember ecosystem it seems.

@ef4
Copy link

ef4 commented Oct 27, 2015

Lots of people use sourcemaps fine, with minification. But it breaks if one of your deps is shipping a bad sourcemaps.

@johnnyshields
Copy link

Is it possible to ignore and warn the bad sourcemap for faulty dep, rather than causing the entire build to fail?

@mrloop
Copy link

mrloop commented Oct 29, 2015

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

@jonesetc
Copy link

jonesetc commented Nov 3, 2015

@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.

@mattmcmanus
Copy link

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.

hacking

@vvscode
Copy link

vvscode commented Dec 11, 2015

@matthiasleitner thx for workaround )

@hussfelt
Copy link

👍 for hack! :)

@fivetanley
Copy link

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.

@mattmcmanus
Copy link

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.

@stefanpenner
Copy link
Contributor

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?

@joostdevries
Copy link
Member

Tracked this down to ember-cli-es5-shim in our project, specifically bower_components/es5-shim/es5-shim.min.js

@Cryrivers
Copy link

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)

@nikz
Copy link

nikz commented Jan 21, 2016

@Cryrivers this might be from another package. I would check all your bower components...

@Cryrivers
Copy link

@nikz

{
  "dependencies": {
    "ember": "2.3.0",
    "ember-cli-shims": "0.1.0",
    "ember-cli-test-loader": "0.2.2",
    "ember-load-initializers": "0.1.7",
    "ember-qunit-notifications": "0.1.0",
    "jquery": "~2.2.0",
    "normalize.css": "~3.0.3",
    "Sortable": "1.4.2",
    "phoneformat": "phoneformat.js#~1.0.2",
    "rangyinputs": "~1.2.0",
    "Caret.js": "caret.js#~0.2.2",
    "animation-frame": "~0.2.4",
    "cropper": "~1.0.0",
    "js-cookie": "^2.0",
    "loader.js": "^3.5.0",
    "socket.io-client": "~1.3.7",
    "json-bigint": "~0.0.0",
    "qunit": "~1.20.0",
    "sanitize.js": "~1.0.0"
  },
  "resolutions": {
    "jquery": "~2.2.0"
  }
}

@johnnyshields
Copy link

EDIT: Some info in this comment was later determined to be incorrect, see discussion here: ember-cli/broccoli-terser-sourcemap#23

Here's an updated repo which reproduces the issue: https://github.com/johnnyshields/ember-sourcemap-issue

I believe I found the problem: ember-cli-uglify requires 3rd-party bower libs to have their magic sourcemap at the BEGINNING of their source, so that Ember CLI can concatenate them like this:

//# sourceMappingURL=lib1.map
lib1.js code

lib2.js code   // this lib doesn't have a sourcemap

//# sourceMappingURL=lib3.map
lib3.js code

If a lib declares the magic comment at the END of its file, the following happens:

lib1.js code

//# sourceMappingURL=lib1.map      ember gets con
lib2.js code

Because Ember CLI evaluates the maps on the CONCATENATED file, here it apparently gets confused and thinks the source map is for lib2 when it's actually for lib1.

So, infact in the original post of this thread, select2 is not the issue--whichever JS comes BEFORE select2 is the issue, but error thrown looks like it's select2.

My sample repo uses sprintf.js as an offender which has magic comment at the end. If you manually edit the sprintf.js to have the magic comment at the beginning, everything works.

@stefanpenner
Copy link
Contributor

Lets transplant this conversation over to: ember-cli/broccoli-terser-sourcemap#23

@johnnyshields
Copy link

@stefanpenner @ef4 Update: I've made a test here: broccolijs/broccoli-concat#50 for what I believe to be the root cause--broccoli-concat is generating an invalid vendor.js/vendor.map which broccoli-uglify-sourcemap chokes on later in the build process.

kemenaran pushed a commit to kemenaran/stations-studio that referenced this issue Mar 29, 2016
Some bugs in the build toolchain causes issues when generating
sourcemaps for some bower libraries. Disabling the JS minification
works around the issue.

See ember-cli/ember-cli-terser#4
hugomaiavieira added a commit to vertragswecker/ember-cli-uglify that referenced this issue Nov 27, 2018
We need to enable the source map generation, but doing so we had this
 issue (ember-cli#4).

To solve it, we need to update the ember-intl to at least version 2.1.0.
The problem is that when updating it we start getting a new error:

```
node_modules/ember-cli-uglify/index.js:6
  included(app) {
          ^
Unexpected token (
```

This is because we are using an old version of node that not deal with
new javascript syntax very well.

So, to fix the issue without the need to the node version right
now, we created this version with this commit on top of the
version 2.1.0.
hugomaiavieira added a commit to vertragswecker/ember-cli-uglify that referenced this issue Nov 27, 2018
We need to enable the source map generation, but doing so we had this
issue (ember-cli#4).

To solve it, we need to update the ember-intl to at least version 2.1.0.
The problem is that when updating it we start getting a new error:

```
node_modules/ember-cli-uglify/index.js:6
  included(app) {
          ^
Unexpected token (
```

This is because we are using an old version of node that not deal with
new javascript syntax very well.

So, to fix the issue without the need to the node version right
now, we created this version with this commit on top of the
version 2.1.0.
@sandstrom
Copy link

I solved this (or a similar issue) by adding this to my ember-cli-build.js config:

    // …
    'ember-cli-terser': {
      terser: {
        compress: {
          sequences: false,
        },
        output: {
          beautify: true,
          semicolons: true,
          comments: false,
          indent_level: 2,
        },
        sourceMap: false, // ADDED
      },
      hiddenSourceMap: true, // ADDED
    },

Perhaps it helps someone else.

@rwjblue
Copy link
Member

rwjblue commented Jan 21, 2021

Since that info is mostly in the README (hiddenSourceMap is mentioned there) I'm going to go ahead and close this. Happy to review/help with PRs to make it clearer though...

@rwjblue rwjblue closed this as completed Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests