You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've run into an issue when using ember-cli-terser and fingerprinting when building for production (or, when both are enabled). After a bit of debugging, I've nailed it down to the order that ember-cli-terser (and thus brocolli-terser-sourcemap) and broccoli-asset-rev run.
Background
Our app is written with both typescript and javascript, so the typescript compiler first compiles and creates sourcemaps for all the files, then babel runs and consumes those sourcemaps and updates them for the generated code. Then when terser runs, it consumes those sourcemaps and updates it for the minified code. Up to this point, everything works perfectly. Using source-map, I can verify that a line in the minified file correctly points to the right line and column in the original typescript file.
The problem comes right after, when broccoli-asset-rev runs. We use it to fingerprint and prepend our CDN url to assets, which changes the column of code in the minified javascript file, but doesn't update the sourcemap. This leads to a case where the line/column combination in the minified, fingerprinted file, no longer match up to the source.
Validation
I've tested this theory by turning off fingerprinting and source maps then work as expected. Additionally, if I disable ember-cli-terser but leave fingerprinting enabled, source maps also work ok. This is because the asset URL changes don't affect the column/line count of the code following it, because it's not minified and all on one line.
Source
Ultimately, I believe the source of the issue is the declaration that ember-cli-terser run beforebroccoli-asset-rev in the package.json config. This has been the case since v1.0.1.
Resolution
I'm not sure if there was a root reason for making ember-cli-uglify run before ember-asset-rev, but I believe it should be set to after. During my testing, I found that switching from before to after still compiles fingerprinted assets correctly, but also maintains the integrity of sourcemaps.
I hope that all made sense, and if you have questions I'd be happy to try and answer them!
The text was updated successfully, but these errors were encountered:
We've run into an issue when using
ember-cli-terser
and fingerprinting when building for production (or, when both are enabled). After a bit of debugging, I've nailed it down to the order thatember-cli-terser
(and thusbrocolli-terser-sourcemap
) andbroccoli-asset-rev
run.Background
Our app is written with both typescript and javascript, so the typescript compiler first compiles and creates sourcemaps for all the files, then babel runs and consumes those sourcemaps and updates them for the generated code. Then when
terser
runs, it consumes those sourcemaps and updates it for the minified code. Up to this point, everything works perfectly. Usingsource-map
, I can verify that a line in the minified file correctly points to the right line and column in the original typescript file.The problem comes right after, when
broccoli-asset-rev
runs. We use it to fingerprint and prepend our CDN url to assets, which changes the column of code in the minified javascript file, but doesn't update the sourcemap. This leads to a case where the line/column combination in the minified, fingerprinted file, no longer match up to the source.Validation
I've tested this theory by turning off fingerprinting and source maps then work as expected. Additionally, if I disable
ember-cli-terser
but leave fingerprinting enabled, source maps also work ok. This is because the asset URL changes don't affect the column/line count of the code following it, because it's not minified and all on one line.Source
Ultimately, I believe the source of the issue is the declaration that
ember-cli-terser
run beforebroccoli-asset-rev
in thepackage.json
config. This has been the case sincev1.0.1
.Resolution
I'm not sure if there was a root reason for making
ember-cli-uglify
run beforeember-asset-rev
, but I believe it should be set toafter
. During my testing, I found that switching frombefore
toafter
still compiles fingerprinted assets correctly, but also maintains the integrity of sourcemaps.I hope that all made sense, and if you have questions I'd be happy to try and answer them!
The text was updated successfully, but these errors were encountered: