Skip to content

Commit

Permalink
fixup! fixup! module: add __esModule to require()'d ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Jul 10, 2024
1 parent 911bbb3 commit ae54d52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/es-module/test-require-module-defined-esmodule.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
// Flags: --experimental-require-module
'use strict';
const common = require('../common');
const mod = require('../fixtures/es-modules/export-es-module.mjs');

// If an ESM already defines __esModule to be something else,
// require(esm) should allow the user override.
common.expectRequiredModule(
mod,
{ default: { hello: 'world' }, __esModule: 'test' },
false,
);
{
const mod = require('../fixtures/es-modules/export-es-module.mjs');
common.expectRequiredModule(
mod,
{ default: { hello: 'world' }, __esModule: 'test' },
false,
);
}

{
const mod = require('../fixtures/es-modules/export-es-module-2.mjs');
common.expectRequiredModule(
mod,
{ default: { hello: 'world' }, __esModule: false },
false,
);
}
2 changes: 2 additions & 0 deletions test/fixtures/es-modules/export-es-module-2.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const __esModule = false;
export default { hello: 'world' };

0 comments on commit ae54d52

Please sign in to comment.