@@ -329,6 +329,9 @@ added:
329
329
- v13.9.0
330
330
- v12.16.2
331
331
changes:
332
+ - version: 20.6.0
333
+ pr-url: https://github.com/nodejs/node/pull/49028
334
+ description: No longer behind the ` --experimental-import-meta-resolve` flag.
332
335
- version: v20.0.0
333
336
pr-url: https://github.com/nodejs/node/pull/44710
334
337
description: This API now returns a string synchronously instead of a Promise.
@@ -348,36 +351,35 @@ changes:
348
351
349
352
* ` specifier` {string} The module specifier to resolve relative to the
350
353
current module.
351
- * Returns: {string} The absolute ( ` file: ` ) URL string for the resolved module .
354
+ * Returns: {string} The absolute URL string that the specifier would resolve to .
352
355
353
356
[` import.meta.resolve` ][] is a module-relative resolution function scoped to
354
357
each module, returning the URL string.
355
358
356
359
` ` ` js
357
360
const dependencyAsset = import .meta.resolve(' component-lib/asset.css' );
358
361
// file:///app/node_modules/component-lib/asset.css
362
+ import .meta.resolve(' ./dep.js' );
363
+ // file:///app/dep.js
359
364
` ` `
360
365
361
366
All features of the Node.js module resolution are supported. Dependency
362
367
resolutions are subject to the permitted exports resolutions within the package.
363
368
364
- ` ` ` js
365
- import .meta.resolve(' ./dep' , import.meta.url);
366
- // file:///app/dep
367
- ` ` `
369
+ **Caveats**:
368
370
369
- > **Caveat** This can result in synchronous file-system operations, which
370
- > can impact performance similarly to ` require .resolve ` .
371
+ * This can result in synchronous file-system operations, which
372
+ can impact performance similarly to ` require .resolve ` .
373
+ * This feature is not available within custom loaders (it would
374
+ create a deadlock).
371
375
372
- Previously, Node.js implemented an asynchronous resolver which also permitted
373
- a second contextual argument. The implementation has since been updated to be
374
- synchronous, with the second contextual ` parent` argument still accessible
375
- behind the ` -- experimental- import -meta-resolve` flag:
376
+ **Non-standard API**:
376
377
377
- * ` parent ` {string|URL} An optional absolute parent module URL to resolve from.
378
+ When using the ` -- experimental- import -meta-resolve` flag, that function accepts
379
+ a second argument:
378
380
379
- > **Caveat** This feature is not available within module customization hooks (it
380
- > would create a deadlock).
381
+ * ` parent ` {string|URL} An optional absolute parent module URL to resolve from.
382
+ **Default:** ` import.meta.url `
381
383
382
384
## Interoperability with CommonJS
383
385
0 commit comments