@@ -752,36 +752,41 @@ changes:
752
752
> signature may change. Do not rely on the API described below.
753
753
754
754
* ` specifier` {string}
755
- * ` context` {Object }
755
+ * ` context` {object }
756
756
* ` conditions` {string\[ ]} Export conditions of the relevant ` package .json `
757
- * ` importAssertions` {Object}
758
- * ` parentURL` {string|undefined} The module importing this one, or undefined
757
+ * ` importAssertions` {object} The object after the ` assert` in an ` import `
758
+ statement, or the value of the ` assert` property in the second argument of
759
+ an ` import()` expression; or an empty object
760
+ * ` parentURL` {string | undefined} The module importing this one, or undefined
759
761
if this is the Node.js entry point
760
762
* ` nextResolve` {Function} The subsequent ` resolve` hook in the chain, or the
761
763
Node.js default ` resolve` hook after the last user-supplied ` resolve` hook
762
764
* ` specifier` {string}
763
- * ` context` {Object }
764
- * Returns: {Object }
765
- * ` format` {string| null| undefined} A hint to the load hook (it might be
765
+ * ` context` {object }
766
+ * Returns: {object }
767
+ * ` format` {string | null | undefined} A hint to the load hook (it might be
766
768
ignored)
767
769
` ' builtin' | ' commonjs' | ' json' | ' module' | ' wasm' `
768
- * ` shortCircuit` {undefined|boolean} A signal that this hook intends to
770
+ * ` importAssertions` {object | undefined} The import assertions to use when
771
+ caching the module (optional; if excluded the input will be used)
772
+ * ` shortCircuit` {undefined | boolean} A signal that this hook intends to
769
773
terminate the chain of ` resolve` hooks. **Default:** ` false`
770
774
* ` url` {string} The absolute URL to which this input resolves
771
775
772
- The ` resolve` hook chain is responsible for resolving file URL for a given
773
- module specifier and parent URL, and optionally its format (such as ` ' module' ` )
774
- as a hint to the ` load` hook. If a format is specified, the ` load` hook is
775
- ultimately responsible for providing the final ` format` value (and it is free to
776
- ignore the hint provided by ` resolve` ); if ` resolve` provides a ` format` , a
777
- custom ` load` hook is required even if only to pass the value to the Node.js
778
- default ` load` hook.
779
-
780
- The module specifier is the string in an ` import ` statement or
781
- ` import()` expression.
782
-
783
- The parent URL is the URL of the module that imported this one, or ` undefined`
784
- if this is the main entry point for the application.
776
+ The ` resolve` hook chain is responsible for telling Node.js where to find and
777
+ how to cache a given ` import` statement or expression. It can optionally return
778
+ its format (such as ` ' module' ` ) as a hint to the ` load` hook. If a format is
779
+ specified, the ` load` hook is ultimately responsible for providing the final
780
+ ` format` value (and it is free to ignore the hint provided by ` resolve` ); if
781
+ ` resolve` provides a ` format` , a custom ` load` hook is required even if only to
782
+ pass the value to the Node.js default ` load` hook.
783
+
784
+ Import assertions are part of the cache key for saving loaded modules into the
785
+ Node.js internal module cache. The ` resolve` hook is responsible for returning
786
+ an ` importAssertions` object if the module should be cached with different
787
+ assertions than were present in the source code (for example, if no assertions
788
+ were present but the module should be cached with assertions
789
+ ` { type : 'json ' }` ).
785
790
786
791
The ` conditions` property in ` context` is an array of conditions for
787
792
[package exports conditions][Conditional Exports] that apply to this resolution
@@ -844,20 +849,20 @@ changes:
844
849
> deprecated, hooks (` getFormat` , ` getSource` , and ` transformSource` ).
845
850
846
851
* ` url` {string} The URL returned by the ` resolve` chain
847
- * ` context` {Object }
852
+ * ` context` {object }
848
853
* ` conditions` {string\[ ]} Export conditions of the relevant ` package .json `
849
- * ` format` {string| null| undefined} The format optionally supplied by the
854
+ * ` format` {string | null | undefined} The format optionally supplied by the
850
855
` resolve` hook chain
851
- * ` importAssertions` {Object }
856
+ * ` importAssertions` {object }
852
857
* ` nextLoad` {Function} The subsequent ` load` hook in the chain, or the
853
858
Node.js default ` load` hook after the last user-supplied ` load` hook
854
859
* ` specifier` {string}
855
- * ` context` {Object }
856
- * Returns: {Object }
860
+ * ` context` {object }
861
+ * Returns: {object }
857
862
* ` format` {string}
858
- * ` shortCircuit` {undefined|boolean} A signal that this hook intends to
863
+ * ` shortCircuit` {undefined |boolean} A signal that this hook intends to
859
864
terminate the chain of ` resolve` hooks. **Default:** ` false `
860
- * ` source` {string| ArrayBuffer| TypedArray} The source for Node.js to evaluate
865
+ * ` source` {string | ArrayBuffer | TypedArray} The source for Node.js to evaluate
861
866
862
867
The ` load` hook provides a way to define a custom method of determining how
863
868
a URL should be interpreted, retrieved, and parsed. It is also in charge of
@@ -941,7 +946,7 @@ changes:
941
946
> In a previous version of this API, this hook was named
942
947
> ` getGlobalPreloadCode` .
943
948
944
- * ` context` {Object } Information to assist the preload code
949
+ * ` context` {object } Information to assist the preload code
945
950
* ` port` {MessagePort}
946
951
* Returns: {string} Code to run before application startup
947
952
0 commit comments