Files
node/test/es-module/test-require-module-dynamic-import-3.js
T
Joyee Cheung 9794d21b07 module: fix submodules loaded by require() and import()
Previously there is an edge case where submodules loaded by require()
may not be loaded by import() again from different intermediate
edges in the graph. This patch fixes that, added tests, and added
debug logs.

Drive-by: make loader a private field so it doesn't show up in logs.
PR-URL: https://github.com/nodejs/node/pull/52487
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2024-04-29 22:46:24 +02:00

15 lines
507 B
JavaScript

// Flags: --experimental-require-module
'use strict';
// This tests that previously synchronously loaded submodule can still
// be loaded by dynamic import().
const common = require('../common');
const assert = require('assert');
(async () => {
const required = require('../fixtures/es-modules/require-and-import/load.cjs');
const imported = await import('../fixtures/es-modules/require-and-import/load.mjs');
assert.deepStrictEqual({ ...required }, { ...imported });
})().then(common.mustCall());