-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs: #37375 (comment)
- Loading branch information
Showing
16 changed files
with
125 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Flags: --experimental-json-modules | ||
import '../common/index.mjs'; | ||
import { rejects, strictEqual } from 'assert'; | ||
|
||
const jsModuleDataUrl = 'data:text/javascript,export{}'; | ||
|
||
await rejects( | ||
import(`data:text/javascript,import${JSON.stringify(jsModuleDataUrl)}assert{type:"json"}`), | ||
{ code: 'ERR_FAILED_IMPORT_ASSERTION' } | ||
); | ||
|
||
await rejects( | ||
import(jsModuleDataUrl, { assert: { type: 'json' } }), | ||
{ code: 'ERR_FAILED_IMPORT_ASSERTION' } | ||
); | ||
|
||
{ | ||
const [secret0, secret1] = await Promise.all([ | ||
import('../fixtures/experimental.json'), | ||
import( | ||
'../fixtures/experimental.json', | ||
{ assert: { type: 'json' } } | ||
), | ||
]); | ||
|
||
strictEqual(secret0.default.ofLife, 42); | ||
strictEqual(secret1.default.ofLife, 42); | ||
strictEqual(secret0.default, secret1.default); | ||
strictEqual(secret0, secret1); | ||
} | ||
|
||
{ | ||
const [secret0, secret1] = await Promise.all([ | ||
import('data:application/json,{"ofLife":42}'), | ||
import( | ||
'data:application/json,{"ofLife":42}', | ||
{ assert: { type: 'json' } } | ||
), | ||
]); | ||
|
||
strictEqual(secret0.default.ofLife, 42); | ||
strictEqual(secret1.default.ofLife, 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Flags: --experimental-json-modules | ||
import '../common/index.mjs'; | ||
import { strictEqual } from 'assert'; | ||
|
||
// eslint-disable-next-line max-len | ||
import secret from '../fixtures/experimental.json' assert { type: 'json', unsupportedAssertion: 'should ignore' }; | ||
|
||
strictEqual(secret.ofLife, 42); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Flags: --experimental-json-modules | ||
import '../common/index.mjs'; | ||
import { strictEqual } from 'assert'; | ||
|
||
import secret0 from '../fixtures/experimental.json' assert { type: 'json' }; | ||
import secret1 from '../fixtures/experimental.json'; | ||
|
||
strictEqual(secret0.ofLife, 42); | ||
strictEqual(secret1.ofLife, 42); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Flags: --experimental-json-modules | ||
import '../common/index.mjs'; | ||
import { strictEqual } from 'assert'; | ||
|
||
import secret from '../fixtures/experimental.json' assert { type: 'json' }; | ||
|
||
strictEqual(secret.ofLife, 42); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../common/index.mjs'; | ||
import 'data:text/javascript,export{}' assert {type:'json'}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
node:internal/errors:* | ||
ErrorCaptureStackTrace(err); | ||
^ | ||
|
||
TypeError [ERR_FAILED_IMPORT_ASSERTION]: Failed to load module "data:text/javascript,export{}", expected type to be "json", got "module" instead | ||
at new NodeError (node:internal/errors:*:*) | ||
at Loader.getModuleJob (node:internal/modules/esm/loader:*:*) | ||
at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:*:*) | ||
at async Promise.all (index 0) | ||
at async link (node:internal/modules/esm/module_job:*:*) { | ||
code: 'ERR_FAILED_IMPORT_ASSERTION' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters