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

Combining fingerprint prepend with sourcemaps omits sourcesContent #10269

Open
f1sherman opened this issue May 4, 2023 · 1 comment
Open

Comments

@f1sherman
Copy link
Contributor

f1sherman commented May 4, 2023

Hello! We've noticed that when we set fingerprint: { prepend: '<A CDN URL>' } along with enabling sourcemaps that the sourcemaps generated omit their sourcesContent. sourcesContent is required by many vendors (e.g. Datadog) to be able to map errors to source code.

You will also see error messages like the below in the build output:

[ember-auto-import-webpack][WARN] (broccoli-terser-sourcemap) "https://cdn.example.com/assets/prepend-and-source-maps-reproduction-case-a6ca85fb815e9c9d4493a774123e7524.map" referenced in "assets/prepend-and-source-maps-reproduction-case-5476e7109a10381ba8972949cc3a7698.js" could not be found
[WARN] (broccoli-terser-sourcemap) "https://cdn.example.com/assets/vendor-fc5c123853c1d6b7328607fa957c4a50.map" referenced in "assets/vendor-a92cf527610392e49247560fa49140ef.js" could not be found

See the reproduction app here.

To reproduce this issue:

  1. Check out the above app
  2. yarn
  3. ember build --environment production
  4. Check the *.map files under dist/assets/ --> note that there is no sourcesContent included in the file
  5. Comment out this line to disable fingerprint prepend
  6. ember build --environment production
  7. Check the *.map files under dist/assets/ --> note that sourcesContent is now included in the file

Output from ember version --verbose && npm --version && yarn --version:

ember-cli: 4.12.1
node: 16.19.1
v8: 9.4.146.26-node.24
uv: 1.43.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.18.1
modules: 93
nghttp2: 1.47.0
napi: 8
llhttp: 6.0.10
openssl: 1.1.1t+quic
cldr: 41.0
icu: 71.1
tz: 2022f
unicode: 14.0
ngtcp2: 0.8.1
nghttp3: 0.7.0
os: darwin arm64
8.19.3
1.22.19
@f1sherman
Copy link
Contributor Author

f1sherman commented May 5, 2023

To be a little more specific in case it helps speed up the fix, I believe the incompatibility is in broccoli-asset-rewrite where it prepends the CDN to the SourceMappingURL.

What happens is that later on when broccoli-terser-sourcemap tries to get the sourcemap so it can create sourcesContent, it can't find it because instead of pointing to a relative location in the filesystem, it ends up pointing to a URL, which it isn't able to handle, leading to warnings like this:

[ember-auto-import-webpack][WARN] (broccoli-terser-sourcemap) "https://cdn.example.com/assets/prepend-and-source-maps-reproduction-case-a6ca85fb815e9c9d4493a774123e7524.map" referenced in "assets/prepend-and-source-maps-reproduction-case-5476e7109a10381ba8972949cc3a7698.js" could not be found
[WARN] (broccoli-terser-sourcemap) "https://cdn.example.com/assets/vendor-fc5c123853c1d6b7328607fa957c4a50.map" referenced in "assets/vendor-a92cf527610392e49247560fa49140ef.js" could not be found

Ultimately I think if we could have an option to not prepend the CDN to SourceMappingURL in broccoli-asset-rewrite, that would fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant