diff --git a/doc/api/esm.md b/doc/api/esm.md index 9f80dcb094e607..c5ef7eb863f6b7 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -324,6 +324,9 @@ added: - v13.9.0 - v12.16.2 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/43363 + description: Convert from asynchronous to synchronous. - version: - v16.2.0 - v14.18.0 @@ -339,15 +342,19 @@ command flag enabled. * `specifier` {string} The module specifier to resolve relative to `parent`. * `parent` {string|URL} The absolute parent module URL to resolve from. If none is specified, the value of `import.meta.url` is used as the default. -* Returns: {Promise} +* Returns: {string} Provides a module-relative resolution function scoped to each module, returning -the URL string. +the URL string. In alignment with browser behavior, this now returns +synchronously. + +> **Caveat** This can result in synchronous file-system operations, which +> can impact performance similarly to `require.resolve`. ```js -const dependencyAsset = await import.meta.resolve('component-lib/asset.css'); +const dependencyAsset = import.meta.resolve('component-lib/asset.css'); ``` `import.meta.resolve` also accepts a second argument which is the parent module @@ -356,11 +363,11 @@ from which to resolve from: ```js -await import.meta.resolve('./dep', import.meta.url); +import.meta.resolve('./dep', import.meta.url); ``` -This function is asynchronous because the ES module resolver in Node.js is -allowed to be asynchronous. +This function is synchronous because the ES module resolver in Node.js is +synchronous. ## Interoperability with CommonJS @@ -731,6 +738,9 @@ prevent unintentional breaks in the chain.