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