diff --git a/doc/api/esm.md b/doc/api/esm.md index 6293779131e4e0..884c3e83c9e684 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -7,6 +7,9 @@ +> **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 -from which to resolve from: - - +from which to resolve: ```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. - ## Interoperability with CommonJS ### `import` statements @@ -730,6 +733,11 @@ A hook that returns without calling `next()` _and_ without returning `shortCircuit: true` also triggers an exception. These errors are to help prevent unintentional breaks in the chain. +Hooks are run in a separate thread, isolated from the main. That means it is a +different [realm](https://tc39.es/ecma262/#realm). The hooks thread may be +terminated by the main thread at any time, so do not depend on asynchronous +operations to (like `console.log`) complete. + #### `resolve(specifier, context, nextResolve)`