Sourcemaps + fingerprinting regression with ember-cli-terser 4.0.2?
The combination of ember-cli-terser 4.0.2, sourcemaps, and asset fingerprinting with the prepend option seems broken. It works with 4.0.1.
The generated sourcemap just has a single file in its "arrays" property. Eg: { "sources":["assets/app-24b6516628ce0829b2e18e768cd8ce2b.js"] , instead of the full list of source files you'd expect.
It appears to work correctly if the fingerprint.prepend option is removed.
May be caused by one of these:
https://github.com/ember-cli/ember-cli-terser/commit/97cef3cab6f912da920f7eeaa8f21e01ca78268b https://github.com/ember-cli/ember-cli-terser/commit/8279c890739388c35ff467cf5cc1d68951a9bdd4
Is this a known problem? I've downgraded to 4.0.1 for now.
I also have an issue with sourcemap fingerprinting in 4.0.2.
The behavior change is demonstrated below. 4.0.2 is giving sourcemaps a unique fingerprint in assetMap.json, but the actual sourcemap file outputted shares its fingerprint with the js file. 4.0.1 does not do this.
Using 4.0.2
// assetMap.json
"assets/test-support.js": "assets/test-support-dbb5b19fdf03c2859ae16e7a1dc9f707.js",
"assets/test-support.map": "assets/test-support-a232a08ab47844d681757e283aac30fb.map",
"assets/vendor.js": "assets/vendor-a63514bff922c4c7f9211ecf9cf9a95c.js",
"assets/vendor.map": "assets/vendor-4548cf25b0650519a3bf0fcebb824d59.map",
% ls dist/assets/ | grep "\.map\|\.js"
test-support-dbb5b19fdf03c2859ae16e7a1dc9f707.js
test-support-dbb5b19fdf03c2859ae16e7a1dc9f707.map
vendor-a63514bff922c4c7f9211ecf9cf9a95c.js
vendor-a63514bff922c4c7f9211ecf9cf9a95c.map
Using 4.0.1
// assetMap.json
"assets/test-support.js": "assets/test-support-89a301f350d8c442d70b96cac2dc78ea.js",
"assets/test-support.map": "assets/test-support-88005702a86610103bf026f97bdad64c.map",
"assets/vendor.js": "assets/vendor-bf70bec9c3a1a3e083ff253e401d322a.js",
"assets/vendor.map": "assets/vendor-db69401ed5c970a866ea1dc33e0fa8b5.map",
% ls dist/assets/ | grep "\.map\|\.js"
test-support-88005702a86610103bf026f97bdad64c.map
test-support-89a301f350d8c442d70b96cac2dc78ea.js
vendor-bf70bec9c3a1a3e083ff253e401d322a.js
vendor-db69401ed5c970a866ea1dc33e0fa8b5.map
And here is my relevant configs from ember-cli-build.js
{
fingerprint: {
enabled: true,
prepend: '[our cdn]',
generateAssetMap: true,
extensions: [
'js', 'css', 'png', 'jpg', 'gif', 'map', // defaults
'ico', 'svg', 'woff', 'woff2', 'ogg' // added by us
],
exclude: [
'assets/inline_svg/**/*',
'assets/dynamic/*'
]
},
sourcemaps: {
enabled: true,
},
'ember-cli-terser': {
enabled: true,
terser: {
compress: false,
mangle: true
}
}
}
We're also seeing a few bugs in 4.0.1 and 4.0.2 and are reverting back to 3.0.0 for that reason. Either the prepended path was missing or it was concatenated incorrectly.
ESBuild had the same issue here: https://github.com/NullVoxPopuli/ember-cli-esbuild/pull/61 and I'm testing out moving broccoli-asset-rev to addon.before right now.
Seeing the same issue here on v4.0.2. Downgrading to v4.0.1 works for me!
Sourcemaps referenced as to a relative path //# sourceMappingURL=app-872148ced72309772aa624ced3dfb68b.map instead of absolute //# sourceMappingURL=https://s3-eu-central-1.amazonaws.com/blabla/assets/app-872148ced72309772aa624ced3dfb68b.map.
Seems like wrong hash is being applied to .map files.
Console output ember build -prod
[TerserWriter][WARN] (broccoli-terser-sourcemap) "https://s3-eu-central-1.amazonaws.com/blabla/assets/app-a7d016737320d4b33763a690926b622f.map" referenced in "assets/app-872148ced72309772aa624ced3dfb68b.js" could not be found
[WARN] (broccoli-terser-sourcemap) "https://s3-eu-central-1.amazonaws.com/blabla/assets/vendor-859e1305b1dc366a97b803eec97b4df5.map" referenced in "assets/vendor-b3eeea38d69cb5b99f35ff8805ab60a3.js" could not be found
Configuration
fingerprint: {
enabled: true,
extensions: [
"pdf",
"js",
"css",
"png",
"jpg",
"gif",
"map",
"otf",
"eot",
"svg",
"ttf",
"woff",
"woff2",
],
prepend: "https://s3-eu-central-1.amazonaws.com/blabla/",
},
sourcemaps: {
enabled: true,
extensions: ["js"],
},
Dist folder contents
-
app-872148ced72309772aa624ced3dfb68b.js -
app-872148ced72309772aa624ced3dfb68b.map -
vendor-4d134e6c58b511425ff083b735069361.css -
vendor-b3eeea38d69cb5b99f35ff8805ab60a3.js -
vendor-b3eeea38d69cb5b99f35ff8805ab60a3.map
Using prepend results in Unexpected token punc «:», expected punc «,» even with sourcemaps disabled, it also results in lots of warnings like this:
[TerserWriter][WARN] (broccoli-terser-sourcemap) "<<CDN URL>>/assets/leaflet/leaflet-4eaa81e6e27a89ed2410a7c39048a397.js.map" referenced in "assets/leaflet/leaflet-4eaa81e6e27a89ed2410a7c39048a397.js" could not be found
Any update on this issue or how to work around it in the meantime? I'm also running into the error
[WARN] (broccoli-terser-sourcemap) "https://my.cdn.com/assets/web-859e1305b1dc366a97b803eec97b4df5.map" referenced in "assets/web-b3eeea38d69cb5b99f35ff8805ab60a3.js" could not be found
Does the problem still exist if broccoli-terser-sourcemap is upgraded to 4.1.1 in your lockfile?
@NullVoxPopuli the warning still exists when running [email protected] & [email protected]
Downgrading to [email protected] while still keeping [email protected] makes the warning go away. But I then run into the issue @apellerano-pw mentioned https://github.com/ember-cli/ember-cli-terser/issues/275#issuecomment-864106140
This came back to bite us a second time - painful!