Fix crash with node.js that has or polyfills fetch() #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
"source-map" v0.7.3 uses
if (typeof fetch === "function")
todifferentiate between browser and node.js environments. If a node.js
environment has
fetch()
-- will be the default in node v18 -- orpolyfills it, then it throws:
You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer
Hi. Thanks for this library!
The "source-map" issue is mozilla/source-map#349 It was fixed in Aug 2018, but there hasn't been a release of "source-map" which includes the fix, except for a "0.8.0-beta.0" beta release. It doesn't appear a non-beta source-map release will happen soon. If it helps give some stability comfort, GoogleChrome/workbox#2712 hit the same issue last year and update to
source-map@0.8.0-beta.0
.There are some "breaking changes" listed in the source-map changelog so I'm not sure if you'd want to bump the major ver of this package before releasing again.
This has come up now because the node.js v18.0.0 nightly builds enabled a Node.js implementation of
fetch()
by default as of last week (nodejs/node#41811). I work on a project that tests with recent Node.js nightly builds. Our tracking issue is: elastic/apm-agent-nodejs#2589