mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 21:15:14 +00:00

The HTML spec has officially landed JSON Modules and as such I think we can move them out of the "experimental" status. They will still be behind the `--experimental-modules` flag until the entire esm implementation moves out of experimental. Refs: https://html.spec.whatwg.org/#creating-a-json-module-script PR-URL: https://github.com/nodejs/node/pull/27752 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
26 lines
902 B
JavaScript
26 lines
902 B
JavaScript
// Flags: --experimental-modules
|
|
import '../common/index.mjs';
|
|
|
|
import { strictEqual, deepStrictEqual } from 'assert';
|
|
|
|
import { createRequireFromPath as createRequire } from 'module';
|
|
import { fileURLToPath as fromURL } from 'url';
|
|
|
|
import mod from '../fixtures/es-modules/json-cache/mod.cjs';
|
|
import another from '../fixtures/es-modules/json-cache/another.cjs';
|
|
import test from '../fixtures/es-modules/json-cache/test.json';
|
|
|
|
const require = createRequire(fromURL(import.meta.url));
|
|
|
|
const modCjs = require('../fixtures/es-modules/json-cache/mod.cjs');
|
|
const anotherCjs = require('../fixtures/es-modules/json-cache/another.cjs');
|
|
const testCjs = require('../fixtures/es-modules/json-cache/test.json');
|
|
|
|
strictEqual(mod.one, 1);
|
|
strictEqual(another.one, 'zalgo');
|
|
strictEqual(test.one, 'it comes');
|
|
|
|
deepStrictEqual(mod, modCjs);
|
|
deepStrictEqual(another, anotherCjs);
|
|
deepStrictEqual(test, testCjs);
|