diff --git a/doc/api/esm.md b/doc/api/esm.md index c5ef7eb863f6b7..9f80dcb094e607 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -324,9 +324,6 @@ 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 @@ -342,19 +339,15 @@ 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: {string} +* Returns: {Promise} Provides a module-relative resolution function scoped to each module, returning -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`. +the URL string. ```js -const dependencyAsset = import.meta.resolve('component-lib/asset.css'); +const dependencyAsset = await import.meta.resolve('component-lib/asset.css'); ``` `import.meta.resolve` also accepts a second argument which is the parent module @@ -363,11 +356,11 @@ from which to resolve from: ```js -import.meta.resolve('./dep', import.meta.url); +await import.meta.resolve('./dep', import.meta.url); ``` -This function is synchronous because the ES module resolver in Node.js is -synchronous. +This function is asynchronous because the ES module resolver in Node.js is +allowed to be asynchronous. ## Interoperability with CommonJS @@ -738,9 +731,6 @@ prevent unintentional breaks in the chain.