-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix handling of sectioned source maps missing 'names' array #29
Fix handling of sectioned source maps missing 'names' array #29
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.
AFAIK just like for regular source maps, the
names
array can be omitted for maps in sectioned/index source maps.
This is incorrect. Each map
in a section is an embedded complete source map object, and a source map object has a non-optional names
array.
src/any-map.ts
Outdated
@@ -111,7 +111,9 @@ function addSection( | |||
const { resolvedSources, sourcesContent: contents } = map; | |||
|
|||
append(sources, resolvedSources); | |||
append(names, map.names); | |||
if (map.names) { | |||
append(names, map.names); |
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.
Instead of doing this here, we can normalize the map
to always contain a names
array. map
is just a TraceMap
instance, so we just need to update
trace-mapping/src/trace-mapping.ts
Line 166 in 5ccfcfe
this.names = names; |
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.
Done
Even though the 'names' array is seen as required, normalize it to an empty array if omitted Currently, trace-mapping will throw with an exception "Cannot read properties of undefined (reading 'length')" in case no 'names' array is provided.
f60214e
to
65818ba
Compare
Thanks for the fast feedback! From reading the spec, it was not entirely clear to me which fields where required, but I see now that only few are declared as "optional". I updated the PR as proposed and amended the existing commit. We'll also fix our index source maps to always include a names array 👍 |
JIRA: CPOUI5FOUNDATION-802 jridgewell/trace-mapping#29 got resolved and merged, but Terser still have not updated their dependency
Even though the
names
array is seen as required, normalize it to an empty array if omittedCurrently, trace-mapping will throw with an exception
"Cannot read properties of undefined (reading 'length')"
in case no 'names' array is provided.