Skip to content

Commit

Permalink
doc: drop import.meta.resolve parent arg URL type
Browse files Browse the repository at this point in the history
I could not find any version of Node.js which accepts a parent URL
argument.  For example, on Node.js 16.1.0, index.mjs with content:

```js
import.meta.resolve('./index.mjs', new URL(import.meta.url));
```

produces:

    node:internal/process/promises:246
              triggerUncaughtException(err, true /* fromPromise */);
              ^

    TypeError [ERR_INVALID_ARG_TYPE]: The "parentURL" argument must be of type string. Received an instance of URL
        at new NodeError (node:internal/errors:363:5)
        at validateString (node:internal/validators:119:11)
        at Loader.resolve (node:internal/modules/esm/loader:87:7)
        at Object.resolve (node:internal/modules/esm/translators:122:26)
        at file:///path/to/index.mjs:1:13
        at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
        at async Loader.import (node:internal/modules/esm/loader:178:24)
        at async Object.loadESM (node:internal/process/esm_loader:68:5) {
      code: 'ERR_INVALID_ARG_TYPE'
    }

Therefore, update the docs to drop the URL type for this argument.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
  • Loading branch information
kevinoid committed May 7, 2021
1 parent 464535b commit 2614203
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/esm.md
Expand Up @@ -287,7 +287,7 @@ This feature is only available with the `--experimental-import-meta-resolve`
command flag enabled.
* `specifier` {string} The module specifier to resolve relative to `parent`.
* `parent` {string|URL} The absolute parent module URL to resolve from. If none
* `parent` {string} The absolute parent module URL to resolve from. If none
is specified, the value of `import.meta.url` is used as the default.
* Returns: {Promise}
Expand Down

0 comments on commit 2614203

Please sign in to comment.