Lines Matching full:path
287 "desc": "<p>The <em>specifier</em> of an <code>import</code> statement is the string after the <code>from</code> keyword,\ne.g. <code>'node:path'</code> in <code>import { sep } from 'node:path'</code>. Specifiers are also\nused in <code>export from</code> statements, and as the argument to an <code>import()</code>\nexpression.</p>\n<p>There are three types of specifiers:</p>\n<ul>\n<li>\n<p><em>Relative specifiers</em> like <code>'./startup.js'</code> or <code>'../config.mjs'</code>. They refer\nto a path relative to the location of the importing file. <em>The file extension\nis always necessary for these.</em></p>\n</li>\n<li>\n<p><em>Bare specifiers</em> like <code>'some-package'</code> or <code>'some-package/shuffle'</code>. They can\nrefer to the main entry point of a package by the package name, or a\nspecific feature module within a package prefixed by the package name as per\nthe examples respectively. <em>Including the file extension is only necessary\nfor packages without an <a href=\"packages.html#exports\"><code>\"exports\"</code></a> field.</em></p>\n</li>\n<li>\n<p><em>Absolute specifiers</em> like <code>'file:///opt/nodejs/config.js'</code>. They refer\ndirectly and explicitly to a full path.</p>\n</li>\n</ul>\n<p>Bare specifier resolutions are handled by the <a href=\"#resolution-algorithm-specification\">Node.js module\nresolution and loading algorithm</a>.\nAll other specifier resolutions are always only resolved with\nthe standard relative <a href=\"https://url.spec.whatwg.org/\">URL</a> resolution semantics.</p>\n<p>Like in CommonJS, module files within packages can be accessed by appending a\npath to the package name unless the package's <a href=\"packages.html#nodejs-packagejson-field-definitions\"><code>package.json</code></a> contains an\n<a href=\"packages.html#exports\"><code>\"exports\"</code></a> field, in which case files within packages can only be accessed\nvia the paths defined in <a href=\"packages.html#exports\"><code>\"exports\"</code></a>.</p>\n<p>For details on these package resolution rules that apply to bare specifiers in\nthe Node.js module resolution, see the <a href=\"packages.html\">packages documentation</a>.</p>",
306 "desc": "<p>Modules are loaded multiple times if the <code>import</code> specifier used to resolve\nthem has a different query or fragment.</p>\n<pre><code class=\"language-js\">import './foo.mjs?query=1'; // loads ./foo.mjs with query of \"?query=1\"\nimport './foo.mjs?query=2'; // loads ./foo.mjs with query of \"?query=2\"\n</code></pre>\n<p>The volume root may be referenced via <code>/</code>, <code>//</code>, or <code>file:///</code>. Given the\ndifferences between <a href=\"https://url.spec.whatwg.org/\">URL</a> and path resolution (such as percent encoding\ndetails), it is recommended to use <a href=\"url.html#urlpathtofileurlpath\">url.pathToFileURL</a> when importing a path.</p>",
481 "desc": "<p>JSON files can be referenced by <code>import</code>:</p>\n<pre><code class=\"language-js\">import packageConfig from './package.json' with { type: 'json' };\n</code></pre>\n<p>The <code>with { type: 'json' }</code> syntax is mandatory; see <a href=\"#import-attributes\">Import Attributes</a>.</p>\n<p>The imported JSON only exposes a <code>default</code> export. There is no support for named\nexports. A cache entry is created in the CommonJS cache to avoid duplication.\nThe same object is returned in CommonJS if the JSON module has already been\nimported from the same path.</p>\n<p><i id=\"esm_experimental_wasm_modules\"></i></p>",
581 "desc": "<p>The algorithm to load an ES module specifier is given through the\n<strong>ESM_RESOLVE</strong> method below. It returns the resolved URL for a\nmodule specifier relative to a parentURL.</p>\n<p>The resolution algorithm determines the full resolved URL for a module\nload, along with its suggested module format. The resolution algorithm\ndoes not determine whether the resolved URL protocol can be loaded,\nor whether the file extensions are permitted, instead these validations\nare applied by Node.js during the load phase\n(for example, if it was asked to load a URL that has a protocol that is\nnot <code>file:</code>, <code>data:</code>, <code>node:</code>, or if <code>--experimental-network-imports</code>\nis enabled, <code>https:</code>).</p>\n<p>The algorithm also tries to determine the format of the file based\non the extension (see <code>ESM_FILE_FORMAT</code> algorithm below). If it does\nnot recognize the file extension (eg if it is not <code>.mjs</code>, <code>.cjs</code>, or\n<code>.json</code>), then a format of <code>undefined</code> is returned,\nwhich will throw during the load phase.</p>\n<p>The algorithm to determine the module format of a resolved URL is\nprovided by <strong>ESM_FILE_FORMAT</strong>, which returns the unique module\nformat for any file. The <em>\"module\"</em> format is returned for an ECMAScript\nModule, while the <em>\"commonjs\"</em> format is used to indicate loading through the\nlegacy CommonJS loader. Additional formats such as <em>\"addon\"</em> can be extended in\nfuture updates.</p>\n<p>In the following algorithms, all subroutine errors are propagated as errors\nof these top-level routines unless stated otherwise.</p>\n<p><em>defaultConditions</em> is the conditional environment name array,\n<code>[\"node\", \"import\"]</code>.</p>\n<p>The resolver can throw the following errors:</p>\n<ul>\n<li><em>Invalid Module Specifier</em>: Module specifier is an invalid URL, package name\nor package subpath specifier.</li>\n<li><em>Invalid Package Configuration</em>: package.json configuration is invalid or\ncontains an invalid configuration.</li>\n<li><em>Invalid Package Target</em>: Package exports or imports define a target module\nfor the package that is an invalid type or string target.</li>\n<li><em>Package Path Not Exported</em>: Package exports do not define or permit a target\nsubpath in the package for the given module.</li>\n<li><em>Package Import Not Defined</em>: Package imports do not define the specifier.</li>\n<li><em>Module Not Found</em>: The package or module requested does not exist.</li>\n<li><em>Unsupported Directory Import</em>: The resolved path corresponds to a directory,\nwhich is not a supported target for module imports.</li>\n</ul>",
588 "desc": "<p><strong>ESM_RESOLVE</strong>(<em>specifier</em>, <em>parentURL</em>)</p>\n<blockquote>\n<ol>\n<li>Let <em>resolved</em> be <strong>undefined</strong>.</li>\n<li>If <em>specifier</em> is a valid URL, then\n<ol>\n<li>Set <em>resolved</em> to the result of parsing and reserializing\n<em>specifier</em> as a URL.</li>\n</ol>\n</li>\n<li>Otherwise, if <em>specifier</em> starts with <em>\"/\"</em>, <em>\"./\"</em>, or <em>\"../\"</em>, then\n<ol>\n<li>Set <em>resolved</em> to the URL resolution of <em>specifier</em> relative to\n<em>parentURL</em>.</li>\n</ol>\n</li>\n<li>Otherwise, if <em>specifier</em> starts with <em>\"#\"</em>, then\n<ol>\n<li>Set <em>resolved</em> to the result of\n<strong>PACKAGE_IMPORTS_RESOLVE</strong>(<em>specifier</em>,\n<em>parentURL</em>, <em>defaultConditions</em>).</li>\n</ol>\n</li>\n<li>Otherwise,\n<ol>\n<li>Note: <em>specifier</em> is now a bare specifier.</li>\n<li>Set <em>resolved</em> the result of\n<strong>PACKAGE_RESOLVE</strong>(<em>specifier</em>, <em>parentURL</em>).</li>\n</ol>\n</li>\n<li>Let <em>format</em> be <strong>undefined</strong>.</li>\n<li>If <em>resolved</em> is a <em>\"file:\"</em> URL, then\n<ol>\n<li>If <em>resolved</em> contains any percent encodings of <em>\"/\"</em> or <em>\"\\\"</em> (<em>\"%2F\"</em>\nand <em>\"%5C\"</em> respectively), then\n<ol>\n<li>Throw an <em>Invalid Module Specifier</em> error.</li>\n</ol>\n</li>\n<li>If the file at <em>resolved</em> is a directory, then\n<ol>\n<li>Throw an <em>Unsupported Directory Import</em> error.</li>\n</ol>\n</li>\n<li>If the file at <em>resolved</em> does not exist, then\n<ol>\n<li>Throw a <em>Module Not Found</em> error.</li>\n</ol>\n</li>\n<li>Set <em>resolved</em> to the real path of <em>resolved</em>, maintaining the\nsame URL querystring and fragment components.</li>\n<li>Set <em>format</em> to the result of <strong>ESM_FILE_FORMAT</strong>(<em>resolved</em>).</li>\n</ol>\n</li>\n<li>Otherwise,\n<ol>\n<li>Set <em>format</em> the module format of the content type associated with the\nURL <em>resolved</em>.</li>\n</ol>\n</li>\n<li>Return <em>format</em> and <em>resolved</em> to the loading phase</li>\n</ol>\n</blockquote>\n<p><strong>PACKAGE_RESOLVE</strong>(<em>packageSpecifier</em>, <em>parentURL</em>)</p>\n<blockquote>\n<ol>\n<li>Let <em>packageName</em> be <strong>undefined</strong>.</li>\n<li>If <em>packageSpecifier</em> is an empty string, then\n<ol>\n<li>Throw an <em>Invalid Module Specifier</em> error.</li>\n</ol>\n</li>\n<li>If <em>packageSpecifier</em> is a Node.js builtin module name, then\n<ol>\n<li>Return the string <em>\"node:\"</em> concatenated with <em>packageSpecifier</em>.</li>\n</ol>\n</li>\n<li>If <em>packageSpecifier</em> does not start with <em>\"@\"</em>, then\n<ol>\n<li>Set <em>packageName</em> to the substring of <em>packageSpecifier</em> until the first\n<em>\"/\"</em> separator or the end of the string.</li>\n</ol>\n</li>\n<li>Otherwise,\n<ol>\n<li>If <em>packageSpecifier</em> does not contain a <em>\"/\"</em> separator, then\n<ol>\n<li>Throw an <em>Invalid Module Specifier</em> error.</li>\n</ol>\n</li>\n<li>Set <em>packageName</em> to the substring of <em>packageSpecifier</em>\nuntil the second <em>\"/\"</em> separator or the end of the string.</li>\n</ol>\n</li>\n<li>If <em>packageName</em> starts with <em>\".\"</em> or contains <em>\"\\\"</em> or <em>\"%\"</em>, then\n<ol>\n<li>Throw an <em>Invalid Module Specifier</em> error.</li>\n</ol>\n</li>\n<li>Let <em>packageSubpath</em> be <em>\".\"</em> concatenated with the substring of\n<em>packageSpecifier</em> from the position at the length of <em>packageName</em>.</li>\n<li>If <em>packageSubpath</em> ends in <em>\"/\"</em>, then\n<ol>\n<li>Throw an <em>Invalid Module Specifier</em> error.</li>\n</ol>\n</li>\n<li>Let <em>selfUrl</em> be the result of\n<strong>PACKAGE_SELF_RESOLVE</strong>(<em>packageName</em>, <em>packageSubpath</em>, <em>parentURL</em>).</li>\n<li>If <em>selfUrl</em> is not <strong>undefined</strong>, return <em>selfUrl</em>.</li>\n<li>While <em>parentURL</em> is not the file system root,\n<ol>\n<li>Let <em>packageURL</em> be the URL resolution of <em>\"node_modules/\"</em>\nconcatenated with <em>packageSpecifier</em>, relative to <em>parentURL</em>.</li>\n<li>Set <em>parentURL</em> to the parent folder URL of <em>parentURL</em>.</li>\n<li>If the folder at <em>packageURL</em> does not exist, then\n<ol>\n<li>Continue the next loop iteration.</li>\n</ol>\n</li>\n<li>Let <em>pjson</em> be the result of <strong>READ_PACKAGE_JSON</strong>(<em>packageURL</em>).</li>\n<li>If <em>pjson</em> is not <strong>null</strong> and <em>pjson</em>.<em>exports</em> is not <strong>null</strong> or\n<strong>undefined</strong>, then\n<ol>\n<li>Return the result of <strong>PACKAGE_EXPORTS_RESOLVE</strong>(<em>packageURL</em>,\n<em>packageSubpath</em>, <em>pjson.exports</em>, <em>defaultConditions</em>).</li>\n</ol>\n</li>\n<li>Otherwise, if <em>packageSubpath</em> is equal to <em>\".\"</em>, then\n<ol>\n<li>If <em>pjson.main</em> is a string, then\n<ol>\n<li>Return the URL resolution of <em>main</em> in <em>packageURL</em>.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Otherwise,\n<ol>\n<li>Return the URL resolution of <em>packageSubpath</em> in <em>packageURL</em>.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Throw a <em>Module Not Found</em> error.</li>\n</ol>\n</blockquote>\n<p><strong>PACKAGE_SELF_RESOLVE</strong>(<em>packageName</em>, <em>packageSubpath</em>, <em>parentURL</em>)</p>\n<blockquote>\n<ol>\n<li>Let <em>packageURL</em> be the result of <strong>LOOKUP_PACKAGE_SCOPE</strong>(<em>parentURL</em>).</li>\n<li>If <em>packageURL</em> is <strong>null</strong>, then\n<ol>\n<li>Return <strong>undefined</strong>.</li>\n</ol>\n</li>\n<li>Let <em>pjson</em> be the result of <strong>READ_PACKAGE_JSON</strong>(<em>packageURL</em>).</li>\n<li>If <em>pjson</em> is <strong>null</strong> or if <em>pjson</em>.<em>exports</em> is <strong>null</strong> or\n<strong>undefined</strong>, then\n<ol>\n<li>Return <strong>undefined</strong>.</li>\n</ol>\n</li>\n<li>If <em>pjson.name</em> is equal to <em>packageName</em>, then\n<ol>\n<li>Return the result of <strong>PACKAGE_EXPORTS_RESOLVE</strong>(<em>packageURL</em>,\n<em>packageSubpath</em>, <em>pjson.exports</em>, <em>defaultConditions</em>).</li>\n</ol>\n</li>\n<li>Otherwise, return <strong>undefined</strong>.</li>\n</ol>\n</blockquote>\n<p><strong>PACKAGE_EXPORTS_RESOLVE</strong>(<em>packageURL</em>, <em>subpath</em>, <em>exports</em>, <em>conditions</em>)</p>\n<blockquote>\n<ol>\n<li>If <em>exports</em> is an Object with both a key starting with <em>\".\"</em> and a key not\nstarting with <em>\".\"</em>, throw an <em>Invalid Package Configuration</em> error.</li>\n<li>If <em>subpath</em> is equal to <em>\".\"</em>, then\n<ol>\n<li>Let <em>mainExport</em> be <strong>undefined</strong>.</li>\n<li>If <em>exports</em> is a String or Array, or an Object containing no keys\nstarting with <em>\".\"</em>, then\n<ol>\n<li>Set <em>mainExport</em> to <em>exports</em>.</li>\n</ol>\n</li>\n<li>Otherwise if <em>exports</em> is an Object containing a <em>\".\"</em> property, then\n<ol>\n<li>Set <em>mainExport</em> to <em>exports</em>[<em>\".\"</em>].</li>\n</ol>\n</li>\n<li>If <em>mainExport</em> is not <strong>undefined</strong>, then\n<ol>\n<li>Let <em>resolved</em> be the result of <strong>PACKAGE_TARGET_RESOLVE</strong>(\n<em>packageURL</em>, <em>mainExport</em>, <strong>null</strong>, <strong>false</strong>, <em>conditions</em>).</li>\n<li>If <em>resolved</em> is not <strong>null</strong> or <strong>undefined</strong>, return <em>resolved</em>.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Otherwise, if <em>exports</em> is an Object and all keys of <em>exports</em> start with\n<em>\".\"</em>, then\n<ol>\n<li>Let <em>matchKey</em> be the string <em>\"./\"</em> concatenated with <em>subpath</em>.</li>\n<li>Let <em>resolved</em> be the result of <strong>PACKAGE_IMPORTS_EXPORTS_RESOLVE</strong>(\n<em>matchKey</em>, <em>exports</em>, <em>packageURL</em>, <strong>false</strong>, <em>conditions</em>).</li>\n<li>If <em>resolved</em> is not <strong>null</strong> or <strong>undefined</strong>, return <em>resolved</em>.</li>\n</ol>\n</li>\n<li>Throw a <em>Package Path Not Exported</em> error.</li>\n</ol>\n</blockquote>\n<p><strong>PACKAGE_IMPORTS_RESOLVE</strong>(<em>specifier</em>, <em>parentURL</em>, <em>conditions</em>)</p>\n<blockquote>\n<ol>\n<li>Assert: <em>specifier</em> begins with <em>\"#\"</em>.</li>\n<li>If <em>specifier</em> is exactly equal to <em>\"#\"</em> or starts with <em>\"#/\"</em>, then\n<ol>\n<li>Throw an <em>Invalid Module Specifier</em> error.</li>\n</ol>\n</li>\n<li>Let <em>packageURL</em> be the result of <strong>LOOKUP_PACKAGE_SCOPE</strong>(<em>parentURL</em>).</li>\n<li>If <em>packageURL</em> is not <strong>null</strong>, then\n<ol>\n<li>Let <em>pjson</em> be the result of <strong>READ_PACKAGE_JSON</strong>(<em>packageURL</em>).</li>\n<li>If <em>pjson.imports</em> is a non-null Object, then\n<ol>\n<li>Let <em>resolved</em> be the result of\n<strong>PACKAGE_IMPORTS_EXPORTS_RESOLVE</strong>(\n<em>specifier</em>, <em>pjson.imports</em>, <em>packageURL</em>, <strong>true</strong>, <em>conditions</em>).</li>\n<li>If <em>resolved</em> is not <strong>null</strong> or <strong>undefined</strong>, return <em>resolved</em>.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Throw a <em>Package Import Not Defined</em> error.</li>\n</ol>\n</blockquote>\n<p><strong>PACKAGE_IMPORTS_EXPORTS_RESOLVE</strong>(<em>matchKey</em>, <em>matchObj</em>, <em>packageURL</em>,\n<em>isImports</em>, <em>conditions</em>)</p>\n<blockquote>\n<ol>\n<li>If <em>matchKey</em> is a key of <em>matchObj</em> and does not contain <em>\"*\"</em>, then\n<ol>\n<li>Let <em>target</em> be the value of <em>matchObj</em>[<em>matchKey</em>].</li>\n<li>Return the result of <strong>PACKAGE_TARGET_RESOLVE</strong>(<em>packageURL</em>,\n<em>target</em>, <strong>null</strong>, <em>isImports</em>, <em>conditions</em>).</li>\n</ol>\n</li>\n<li>Let <em>expansionKeys</em> be the list of keys of <em>matchObj</em> containing only a\nsingle <em>\"*\"</em>, sorted by the sorting function <strong>PATTERN_KEY_COMPARE</strong>\nwhich orders in descending order of specificity.</li>\n<li>For each key <em>expansionKey</em> in <em>expansionKeys</em>, do\n<ol>\n<li>Let <em>patternBase</em> be the substring of <em>expansionKey</em> up to but excluding\nthe first <em>\"*\"</em> character.</li>\n<li>If <em>matchKey</em> starts with but is not equal to <em>patternBase</em>, then\n<ol>\n<li>Let <em>patternTrailer</em> be the substring of <em>expansionKey</em> from the\nindex after the first <em>\"*\"</em> character.</li>\n<li>If <em>patternTrailer</em> has zero length, or if <em>matchKey</em> ends with\n<em>patternTrailer</em> and the length of <em>matchKey</em> is greater than or\nequal to the length of <em>expansionKey</em>, then\n<ol>\n<li>Let <em>target</em> be the value of <em>matchObj</em>[<em>expansionKey</em>].</li>\n<li>Let <em>patternMatch</em> be the substring of <em>matchKey</em> starting at the\nindex of the length of <em>patternBase</em> up to the length of\n<em>matchKey</em> minus the length of <em>patternTrailer</em>.</li>\n<li>Return the result of <strong>PACKAGE_TARGET_RESOLVE</strong>(<em>packageURL</em>,\n<em>target</em>, <em>patternMatch</em>, <em>isImports</em>, <em>conditions</em>).</li>\n</ol>\n</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Return <strong>null</strong>.</li>\n</ol>\n</blockquote>\n<p><strong>PATTERN_KEY_COMPARE</strong>(<em>keyA</em>, <em>keyB</em>)</p>\n<blockquote>\n<ol>\n<li>Assert: <em>keyA</em> ends with <em>\"/\"</em> or contains only a single <em>\"*\"</em>.</li>\n<li>Assert: <em>keyB</em> ends with <em>\"/\"</em> or contains only a single <em>\"*\"</em>.</li>\n<li>Let <em>baseLengthA</em> be the index of <em>\"*\"</em> in <em>keyA</em> plus one, if <em>keyA</em>\ncontains <em>\"*\"</em>, or the length of <em>keyA</em> otherwise.</li>\n<li>Let <em>baseLengthB</em> be the index of <em>\"*\"</em> in <em>keyB</em> plus one, if <em>keyB</em>\ncontains <em>\"*\"</em>, or the length of <em>keyB</em> otherwise.</li>\n<li>If <em>baseLengthA</em> is greater than <em>baseLengthB</em>, return -1.</li>\n<li>If <em>baseLengthB</em> is greater than <em>baseLengthA</em>, return 1.</li>\n<li>If <em>keyA</em> does not contain <em>\"*\"</em>, return 1.</li>\n<li>If <em>keyB</em> does not contain <em>\"*\"</em>, return -1.</li>\n<li>If the length of <em>keyA</em> is greater than the length of <em>keyB</em>, return -1.</li>\n<li>If the length of <em>keyB</em> is greater than the length of <em>keyA</em>, return 1.</li>\n<li>Return 0.</li>\n</ol>\n</blockquote>\n<p><strong>PACKAGE_TARGET_RESOLVE</strong>(<em>packageURL</em>, <em>target</em>, <em>patternMatch</em>,\n<em>isImports</em>, <em>conditions</em>)</p>\n<blockquote>\n<ol>\n<li>If <em>target</em> is a String, then\n<ol>\n<li>If <em>target</em> does not start with <em>\"./\"</em>, then\n<ol>\n<li>If <em>isImports</em> is <strong>false</strong>, or if <em>target</em> starts with <em>\"../\"</em> or\n<em>\"/\"</em>, or if <em>target</em> is a valid URL, then\n<ol>\n<li>Throw an <em>Invalid Package Target</em> error.</li>\n</ol>\n</li>\n<li>If <em>patternMatch</em> is a String, then\n<ol>\n<li>Return <strong>PACKAGE_RESOLVE</strong>(<em>target</em> with every instance of <em>\"*\"</em>\nreplaced by <em>patternMatch</em>, <em>packageURL</em> + <em>\"/\"</em>).</li>\n</ol>\n</li>\n<li>Return <strong>PACKAGE_RESOLVE</strong>(<em>target</em>, <em>packageURL</em> + <em>\"/\"</em>).</li>\n</ol>\n</li>\n<li>If <em>target</em> split on <em>\"/\"</em> or <em>\"\\\"</em> contains any <em>\"\"</em>, <em>\".\"</em>, <em>\"..\"</em>,\nor <em>\"node_modules\"</em> segments after the first <em>\".\"</em> segment, case\ninsensitive and including percent encoded variants, throw an <em>Invalid\nPackage Target</em> error.</li>\n<li>Let <em>resolvedTarget</em> be the URL resolution of the concatenation of\n<em>packageURL</em> and <em>target</em>.</li>\n<li>Assert: <em>resolvedTarget</em> is contained in <em>packageURL</em>.</li>\n<li>If <em>patternMatch</em> is <strong>null</strong>, then\n<ol>\n<li>Return <em>resolvedTarget</em>.</li>\n</ol>\n</li>\n<li>If <em>patternMatch</em> split on <em>\"/\"</em> or <em>\"\\\"</em> contains any <em>\"\"</em>, <em>\".\"</em>,\n<em>\"..\"</em>, or <em>\"node_modules\"</em> segments, case insensitive and including\npercent encoded variants, throw an <em>Invalid Module Specifier</em> error.</li>\n<li>Return the URL resolution of <em>resolvedTarget</em> with every instance of\n<em>\"*\"</em> replaced with <em>patternMatch</em>.</li>\n</ol>\n</li>\n<li>Otherwise, if <em>target</em> is a non-null Object, then\n<ol>\n<li>If <em>exports</em> contains any index property keys, as defined in ECMA-262\n<a href=\"https://tc39.es/ecma262/#integer-index\">6.1.7 Array Index</a>, throw an <em>Invalid Package Configuration</em> error.</li>\n<li>For each property <em>p</em> of <em>target</em>, in object insertion order as,\n<ol>\n<li>If <em>p</em> equals <em>\"default\"</em> or <em>conditions</em> contains an entry for <em>p</em>,\nthen\n<ol>\n<li>Let <em>targetValue</em> be the value of the <em>p</em> property in <em>target</em>.</li>\n<li>Let <em>resolved</em> be the result of <strong>PACKAGE_TARGET_RESOLVE</strong>(\n<em>packageURL</em>, <em>targetValue</em>, <em>patternMatch</em>, <em>isImports</em>,\n<em>conditions</em>).</li>\n<li>If <em>resolved</em> is equal to <strong>undefined</strong>, continue the loop.</li>\n<li>Return <em>resolved</em>.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Return <strong>undefined</strong>.</li>\n</ol>\n</li>\n<li>Otherwise, if <em>target</em> is an Array, then\n<ol>\n<li>If _target.length is zero, return <strong>null</strong>.</li>\n<li>For each item <em>targetValue</em> in <em>target</em>, do\n<ol>\n<li>Let <em>resolved</em> be the result of <strong>PACKAGE_TARGET_RESOLVE</strong>(\n<em>packageURL</em>, <em>targetValue</em>, <em>patternMatch</em>, <em>isImports</em>,\n<em>conditions</em>), continuing the loop on any <em>Invalid Package Target</em>\nerror.</li>\n<li>If <em>resolved</em> is <strong>undefined</strong>, continue the loop.</li>\n<li>Return <em>resolved</em>.</li>\n</ol>\n</li>\n<li>Return or throw the last fallback resolution <strong>null</strong> return or error.</li>\n</ol>\n</li>\n<li>Otherwise, if <em>target</em> is <em>null</em>, return <strong>null</strong>.</li>\n<li>Otherwise throw an <em>Invalid Package Target</em> error.</li>\n</ol>\n</blockquote>\n<p><strong>ESM_FILE_FORMAT</strong>(<em>url</em>)</p>\n<blockquote>\n<ol>\n<li>Assert: <em>url</em> corresponds to an existing file.</li>\n<li>If <em>url</em> ends in <em>\".mjs\"</em>, then\n<ol>\n<li>Return <em>\"module\"</em>.</li>\n</ol>\n</li>\n<li>If <em>url</em> ends in <em>\".cjs\"</em>, then\n<ol>\n<li>Return <em>\"commonjs\"</em>.</li>\n</ol>\n</li>\n<li>If <em>url</em> ends in <em>\".json\"</em>, then\n<ol>\n<li>Return <em>\"json\"</em>.</li>\n</ol>\n</li>\n<li>Let <em>packageURL</em> be the result of <strong>LOOKUP_PACKAGE_SCOPE</strong>(<em>url</em>).</li>\n<li>Let <em>pjson</em> be the result of <strong>READ_PACKAGE_JSON</strong>(<em>packageURL</em>).</li>\n<li>If <em>pjson?.type</em> exists and is <em>\"module\"</em>, then\n<ol>\n<li>If <em>url</em> ends in <em>\".js\"</em> or has no file extension, then\n<ol>\n<li>If <code>--experimental-wasm-modules</code> is enabled and the file at <em>url</em>\ncontains the header for a WebAssembly module, then\n<ol>\n<li>Return <em>\"wasm\"</em>.</li>\n</ol>\n</li>\n<li>Otherwise,\n<ol>\n<li>Return <em>\"module\"</em>.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Return <strong>undefined</strong>.</li>\n</ol>\n</li>\n<li>Otherwise,\n<ol>\n<li>Return <strong>undefined</strong>.</li>\n</ol>\n</li>\n</ol>\n</blockquote>\n<p><strong>LOOKUP_PACKAGE_SCOPE</strong>(<em>url</em>)</p>\n<blockquote>\n<ol>\n<li>Let <em>scopeURL</em> be <em>url</em>.</li>\n<li>While <em>scopeURL</em> is not the file system root,\n<ol>\n<li>Set <em>scopeURL</em> to the parent URL of <em>scopeURL</em>.</li>\n<li>If <em>scopeURL</em> ends in a <em>\"node_modules\"</em> path segment, return <strong>null</strong>.</li>\n<li>Let <em>pjsonURL</em> be the resolution of <em>\"package.json\"</em> within\n<em>scopeURL</em>.</li>\n<li>if the file at <em>pjsonURL</em> exists, then\n<ol>\n<li>Return <em>scopeURL</em>.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Return <strong>null</strong>.</li>\n</ol>\n</blockquote>\n<p><strong>READ_PACKAGE_JSON</strong>(<em>packageURL</em>)</p>\n<blockquote>\n<ol>\n<li>Let <em>pjsonURL</em> be the resolution of <em>\"package.json\"</em> within <em>packageURL</em>.</li>\n<li>If the file at <em>pjsonURL</em> does not exist, then\n<ol>\n<li>Return <strong>null</strong>.</li>\n</ol>\n</li>\n<li>If the file at <em>packageURL</em> does not parse as valid JSON, then\n<ol>\n<li>Throw an <em>Invalid Package Configuration</em> error.</li>\n</ol>\n</li>\n<li>Return the parsed JSON source of the file at <em>pjsonURL</em>.</li>\n</ol>\n</blockquote>",
597 "desc": "<blockquote>\n<p>Do not rely on this flag. We plan to remove it once the\n<a href=\"module.html#customization-hooks\">Module customization hooks</a> have advanced to the point that equivalent\nfunctionality can be achieved via custom hooks.</p>\n</blockquote>\n<p>The current specifier resolution does not support all default behavior of\nthe CommonJS loader. One of the behavior differences is automatic resolution\nof file extensions and the ability to import directories that have an index\nfile.</p>\n<p>The <code>--experimental-specifier-resolution=[mode]</code> flag can be used to customize\nthe extension resolution algorithm. The default mode is <code>explicit</code>, which\nrequires the full path to a module be provided to the loader. To enable the\nautomatic extension resolution and importing from directories that include an\nindex file use the <code>node</code> mode.</p>\n<pre><code class=\"language-console\">$ node index.mjs\nsuccess!\n$ node index # Failure!\nError: Cannot find module\n$ node --experimental-specifier-resolution=node index\nsuccess!\n</code></pre>\n<!-- Note: The cjs-module-lexer link should be kept in-sync with the deps version -->",