-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
module: ensure successful dynamic import returns the same result #46662
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
Changes from 1 commit
0f1fe00
3bf7e02
9f36bf7
aabe393
be69edd
dd06864
631d7c6
c279d18
56a8a07
abf105a
00ea14c
a791dc9
3638858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com> Co-authored-by: Jordan Harband <ljharb@gmail.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ const { validateString } = require('internal/validators'); | |||||
| * Future resolutions of the same input (specifier, parent URL and import assertions) | ||||||
| * must return the same result if the first attempt was successful, per | ||||||
| * https://tc39.es/ecma262/#sec-HostLoadImportedModule. | ||||||
| * This cache is *not* used when custom loaders are registered. | ||||||
| */ | ||||||
| class ResolveCache extends SafeMap { | ||||||
| constructor(i) { super(i); } // eslint-disable-line no-useless-constructor | ||||||
|
|
@@ -33,9 +34,9 @@ class ResolveCache extends SafeMap { | |||||
| * @returns {string} | ||||||
| */ | ||||||
| serializeKey(specifier, importAssertions) { | ||||||
| // To serialize the ModuleRequest (specifier + list of import attributes), | ||||||
| // we need to sort the attributes by key, then stringifying, | ||||||
| // so that different import statements with the same attributes are always treated | ||||||
| // To serialize the ModuleRequest (specifier + list of import assertions), | ||||||
| // we need to sort the assertions by key, then stringifying, | ||||||
| // so that different import statements with the same assertions are always treated | ||||||
| // as identical. | ||||||
| return specifier + '::' + ArrayPrototypeJoin( | ||||||
| ArrayPrototypeMap( | ||||||
|
|
@@ -44,7 +45,7 @@ class ResolveCache extends SafeMap { | |||||
| ','); | ||||||
|
aduh95 marked this conversation as resolved.
|
||||||
| } | ||||||
|
|
||||||
| #getInternalCache(parentURL) { | ||||||
| #getModuleCachedImports(parentURL) { | ||||||
| let internalCache = super.get(parentURL); | ||||||
| if (internalCache == null) { | ||||||
| super.set(parentURL, internalCache = { __proto__: null }); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And associated changes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not going to do that in this PR, if
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. @JakobJingleheimer if you still do a refactor after this, maybe add this to the list of improvements? |
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.