Skip to content

Commit

Permalink
Add data: test and fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners committed Jul 12, 2023
1 parent d864bbc commit cf0841f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ added: REPLACEME
* {string} The directory name of the current module. This is the same as the
[`path.dirname()`][] of the [`import.meta.__filename`][].

> **Caveat** only local modules support this property. Modules not using the `file:` protocol will
> not provide it.
> **Caveat** only local modules support this property. Modules not using the
> `file:` protocol will not provide it.
### `import.meta.__filename`

Expand All @@ -330,8 +330,8 @@ added: REPLACEME
file's absolute path with symlinks resolved. This is the same as the
[`url.fileURLToPath()`][] of the [`import.meta.url`][].

> **Caveat** only local modules support this property. Modules not using the `file:` protocol will
> not provide it.
> **Caveat** only local modules support this property. Modules not using the
> `file:` protocol will not provide it.
### `import.meta.url`

Expand Down Expand Up @@ -1624,7 +1624,6 @@ for ESM specifiers is [commonjs-extension-resolution-loader][].
[`data:` URLs]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
[`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
[`import()`]: #import-expressions
[`import.meta.__dirname`]: #importmeta__dirname
[`import.meta.__filename`]: #importmeta__filename
[`import.meta.resolve`]: #importmetaresolvespecifier-parent
[`import.meta.url`]: #importmetaurl
Expand Down
4 changes: 4 additions & 0 deletions test/es-module/test-esm-import-meta.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ assert(import.meta.__dirname.match(dirReg));

const fileReg = /^\/.*\/test\/es-module\/test-esm-import-meta\.mjs$/;
assert(import.meta.__filename.match(fileReg));

// Verify that `data:` imports do not behave like `file:` imports.
import dataDirname from 'data:text/javascript,const a = import.meta.__dirname;export default a;';
assert.strictEqual(dataDirname, undefined);

0 comments on commit cf0841f

Please sign in to comment.