mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
The old import assertions proposal has been renamed to "import attributes" with the follwing major changes: 1. The keyword is now `with` instead of `assert`. 2. Unknown assertions cause an error rather than being ignored, This commit updates the documentation to encourage folks to use the new syntax, and add aliases for module customization hooks. PR-URL: https://github.com/nodejs/node/pull/50140 Fixes: https://github.com/nodejs/node/issues/50134 Refs: https://github.com/v8/v8/commit/159c82c5e6392e78b9bba7161b1bed6e23758984 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import '../common/index.mjs';
|
|
import { strictEqual } from 'assert';
|
|
|
|
{
|
|
const results = await Promise.allSettled([
|
|
import('../fixtures/empty.js', { with: { type: 'json' } }),
|
|
import('../fixtures/empty.js'),
|
|
]);
|
|
|
|
strictEqual(results[0].status, 'rejected');
|
|
strictEqual(results[1].status, 'fulfilled');
|
|
}
|
|
|
|
{
|
|
const results = await Promise.allSettled([
|
|
import('../fixtures/empty.js'),
|
|
import('../fixtures/empty.js', { with: { type: 'json' } }),
|
|
]);
|
|
|
|
strictEqual(results[0].status, 'fulfilled');
|
|
strictEqual(results[1].status, 'rejected');
|
|
}
|
|
|
|
{
|
|
const results = await Promise.allSettled([
|
|
import('../fixtures/empty.json', { with: { type: 'json' } }),
|
|
import('../fixtures/empty.json'),
|
|
]);
|
|
|
|
strictEqual(results[0].status, 'fulfilled');
|
|
strictEqual(results[1].status, 'rejected');
|
|
}
|
|
|
|
{
|
|
const results = await Promise.allSettled([
|
|
import('../fixtures/empty.json'),
|
|
import('../fixtures/empty.json', { with: { type: 'json' } }),
|
|
]);
|
|
|
|
strictEqual(results[0].status, 'rejected');
|
|
strictEqual(results[1].status, 'fulfilled');
|
|
}
|