-
Notifications
You must be signed in to change notification settings - Fork 818
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
Account for injectManifest replacements in sourcemaps #2239
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this! I know working with source maps is complex, so if there are any edge cases we can address them as they arise.
PR-Bot Size PluginChanged File Sizes
New FilesNo new files have been added. All File SizesView Table
Workbox Aggregate Size Plugin3.51KB gzip'ed (23% of limit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed #3233 thinking there was no support in injectManifest
, but I now see the root issues per my comments below. In short, the source map file and reference URL in the new source file will only be correct when swSrc
and swDest
are in different directories with the same filename, with their corresponding maps in the same folders.
// See https://github.com/GoogleChrome/workbox/issues/2235 | ||
if (url) { | ||
const sourcemapSrcPath = upath.resolve(upath.dirname(options.swSrc), url); | ||
const sourcemapDestPath = upath.resolve(upath.dirname(options.swDest), url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always keep the same source map filename, and if swSrc
and swDest
are in the same folder, it'll overwrite the original source map file.
Instead, this should just append ".map" to swDest
.
|
||
return { | ||
map: JSON.stringify(updatedSourceMap), | ||
source: src, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is returned without changing the URL of the source map to reflect the filename in swDest
.
R: @philipwalton
Fixes #2235
This was quite a rabbit hole to go down.
Ultimately, I think the code that I ended up with to modify an existing sourcemap to account for the injected manifest does the job, but I would not be shocked if there are some edge cases that I'm not aware of.