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

[DevTools] Handle bundles (multi sources) when parsing hook names #21794

Closed
bvaughn opened this issue Jul 2, 2021 · 0 comments · Fixed by #21790
Closed

[DevTools] Handle bundles (multi sources) when parsing hook names #21794

bvaughn opened this issue Jul 2, 2021 · 0 comments · Fixed by #21790

Comments

@bvaughn
Copy link
Contributor

bvaughn commented Jul 2, 2021

DevTools hooks name parsing code currently assumes a single "source" for the source map:

// Now that the source map has been loaded,
// extract the original source for later.
const source = sourceMapContents.sources[0];
const originalSourceCode = sourceConsumer.sourceContentFor(
source,
true,
);

But as pointed out by comment #21641 (comment):

If the compiled code is a bundle, it can consist of multiple modules - what guarantees that sources[0] is the correct module for the hook we'll be looking up? The originalPositionFor call in findHookNames above returns a source property which we currently ignore; I think the correct thing to do is to lazily parse/cache the source at that point rather than make this assumption here.

@bvaughn bvaughn changed the title [DevTools] Handle multiple sources [DevTools] Handle multiple sources (bundles) when parsing hook names Jul 2, 2021
@bvaughn bvaughn changed the title [DevTools] Handle multiple sources (bundles) when parsing hook names [DevTools] Handle bundles (multi sources) when parsing hook names Jul 2, 2021
@motiz88 motiz88 self-assigned this Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants