Stability: 1 - Experimental
specifier
{string} The module specifier to resolve relative toparent
.parent
{string|URL} The absolute parent module URL to resolve from. If none is specified, the value ofimport.meta.url
is used as the default.- Returns: {Promise}
Provides a module-relative resolution function scoped to each module, returning the URL string.
const dependencyAsset = await 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:
await import.meta.resolve('./dep', import.meta.url);
This function is asynchronous because the ES module resolver in Node.js is allowed to be asynchronous.