diff options
author | Jan Krems <jan.krems@gmail.com> | 2020-05-21 09:40:29 -0700 |
---|---|---|
committer | Jan Krems <jan.krems@gmail.com> | 2020-05-27 16:38:38 -0700 |
commit | d12d5ef3ef8e5d9f6a755d72c4b8ddc82658dee9 (patch) | |
tree | 6c7b333e848cd3f7d9eb61f0cc14b03e48763c22 /doc | |
parent | 54b36e401d2b72d95e5f1dbbc787f6beed639347 (diff) | |
download | node-new-d12d5ef3ef8e5d9f6a755d72c4b8ddc82658dee9.tar.gz |
module: remove dynamicInstantiate loader hook
The dynamicInstantiate loader hook requires that the hooks run in the
same global scope as the code being loaded. We don't want to commit to
this being true in the future. It stops us from sharing hooks between
multiple worker threads or isolating loader hook from the application
code.
Using `getSource` and `getGlobalPreloadCode` the same use cases should
be covered.
PR-URL: https://github.com/nodejs/node/pull/33501
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/errors.md | 14 | ||||
-rw-r--r-- | doc/api/esm.md | 35 |
2 files changed, 0 insertions, 49 deletions
diff --git a/doc/api/errors.md b/doc/api/errors.md index 17c0a9e7c6..d9e142bcd0 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1575,14 +1575,6 @@ strict compliance with the API specification (which in some cases may accept `func(undefined)` and `func()` are treated identically, and the [`ERR_INVALID_ARG_TYPE`][] error code may be used instead. -<a id="ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK"></a> -### `ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK` - -> Stability: 1 - Experimental - -An [ES Module][] loader hook specified `format: 'dynamic'` but did not provide -a `dynamicInstantiate` hook. - <a id="ERR_MISSING_OPTION"></a> ### `ERR_MISSING_OPTION` @@ -2526,12 +2518,6 @@ while trying to read and parse it. The `--entry-type=...` flag is not compatible with the Node.js REPL. -<a id="ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK"></a> -#### `ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK` - -Used when an [ES Module][] loader hook specifies `format: 'dynamic'` but does -not provide a `dynamicInstantiate` hook. - <a id="ERR_FEATURE_UNAVAILABLE_ON_PLATFORM"></a> #### `ERR_FEATURE_UNAVAILABLE_ON_PLATFORM` diff --git a/doc/api/esm.md b/doc/api/esm.md index f8a7595a72..38885d7a0b 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -1204,7 +1204,6 @@ of the following: | --- | --- | --- | | `'builtin'` | Load a Node.js builtin module | Not applicable | | `'commonjs'` | Load a Node.js CommonJS module | Not applicable | -| `'dynamic'` | Use a [dynamic instantiate hook][] | Not applicable | | `'json'` | Load a JSON file | { [ArrayBuffer][], [string][], [TypedArray][] } | | `'module'` | Load an ES module | { [ArrayBuffer][], [string][], [TypedArray][] } | | `'wasm'` | Load a WebAssembly module | { [ArrayBuffer][], [string][], [TypedArray][] } | @@ -1345,38 +1344,6 @@ const require = createRequire(process.cwd() + '/<preload>'); } ``` -#### <code>dynamicInstantiate</code> hook - -> Note: The loaders API is being redesigned. This hook may disappear or its -> signature may change. Do not rely on the API described below. - -To create a custom dynamic module that doesn't correspond to one of the -existing `format` interpretations, the `dynamicInstantiate` hook can be used. -This hook is called only for modules that return `format: 'dynamic'` from -the [`getFormat` hook][]. - -```js -/** - * @param {string} url - * @returns {object} response - * @returns {array} response.exports - * @returns {function} response.execute - */ -export async function dynamicInstantiate(url) { - return { - exports: ['customExportName'], - execute: (exports) => { - // Get and set functions provided for pre-allocated export names - exports.customExportName.set('value'); - } - }; -} -``` - -With the list of module exports provided upfront, the `execute` function will -then be called at the exact point of module evaluation order for that module -in the import tree. - ### Examples The various loader hooks can be used together to accomplish wide-ranging @@ -1846,7 +1813,6 @@ success! [`data:` URLs]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs [`esm`]: https://github.com/standard-things/esm#readme [`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export -[`getFormat` hook]: #esm_code_getformat_code_hook [`import()`]: #esm_import_expressions [`import.meta.url`]: #esm_import_meta [`import`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import @@ -1859,7 +1825,6 @@ success! [TypedArray]: http://www.ecma-international.org/ecma-262/6.0/#sec-typedarray-objects [Uint8Array]: http://www.ecma-international.org/ecma-262/6.0/#sec-uint8array [`util.TextDecoder`]: util.html#util_class_util_textdecoder -[dynamic instantiate hook]: #esm_code_dynamicinstantiate_code_hook [import an ES or CommonJS module for its side effects only]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Import_a_module_for_its_side_effects_only [special scheme]: https://url.spec.whatwg.org/#special-scheme [the full specifier path]: #esm_mandatory_file_extensions |