Skip to content

Commit cf0841f

Browse files
committed
Add data: test and fix linting errors
1 parent d864bbc commit cf0841f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

doc/api/esm.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ added: REPLACEME
317317
* {string} The directory name of the current module. This is the same as the
318318
[`path.dirname()`][] of the [`import.meta.__filename`][].
319319

320-
> **Caveat** only local modules support this property. Modules not using the `file:` protocol will
321-
> not provide it.
320+
> **Caveat** only local modules support this property. Modules not using the
321+
> `file:` protocol will not provide it.
322322
323323
### `import.meta.__filename`
324324

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

333-
> **Caveat** only local modules support this property. Modules not using the `file:` protocol will
334-
> not provide it.
333+
> **Caveat** only local modules support this property. Modules not using the
334+
> `file:` protocol will not provide it.
335335
336336
### `import.meta.url`
337337

@@ -1624,7 +1624,6 @@ for ESM specifiers is [commonjs-extension-resolution-loader][].
16241624
[`data:` URLs]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
16251625
[`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
16261626
[`import()`]: #import-expressions
1627-
[`import.meta.__dirname`]: #importmeta__dirname
16281627
[`import.meta.__filename`]: #importmeta__filename
16291628
[`import.meta.resolve`]: #importmetaresolvespecifier-parent
16301629
[`import.meta.url`]: #importmetaurl

test/es-module/test-esm-import-meta.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ assert(import.meta.__dirname.match(dirReg));
2424

2525
const fileReg = /^\/.*\/test\/es-module\/test-esm-import-meta\.mjs$/;
2626
assert(import.meta.__filename.match(fileReg));
27+
28+
// Verify that `data:` imports do not behave like `file:` imports.
29+
import dataDirname from 'data:text/javascript,const a = import.meta.__dirname;export default a;';
30+
assert.strictEqual(dataDirname, undefined);

0 commit comments

Comments
 (0)