Skip to content

Commit b2f221f

Browse files
committed
further review findings
1 parent 3b4caab commit b2f221f

File tree

6 files changed

+34
-28
lines changed

6 files changed

+34
-28
lines changed

lib/internal/modules/esm/get_format.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const { containsModuleSyntax } = internalBinding('contextify');
2323
const { getPackageScopeConfig, getPackageType } = require('internal/modules/package_json_reader');
2424
const { fileURLToPath } = require('internal/url');
2525
const { readFileSync } = require('fs');
26-
const { Buffer } = require('buffer');
2726
const { ERR_UNKNOWN_FILE_EXTENSION } = require('internal/errors').codes;
2827

2928
const protocolHandlers = {

test/es-module/test-esm-detect-ambiguous.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('--experimental-detect-module', { concurrency: !process.env.TEST_PARALL
168168
});
169169
}
170170

171-
it('should hint format correctly for extensionles modules resolve hook', async () => {
171+
it('should hint format correctly for the resolve hook for extensionless modules', async () => {
172172
let writeSync;
173173
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
174174
'--experimental-detect-module',

test/es-module/test-esm-loader-hooks.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,29 @@ describe('Loader hooks', { concurrency: !process.env.TEST_PARALLEL }, () => {
781781
}
782782
});
783783

784+
describe('should use ESM loaders ', async () => {
785+
for (const { testConfigName, additionalOptions } of [
786+
{ testConfigName: 'without --experimental-detect-module', additionalOptions: [] },
787+
{ testConfigName: 'with --experimental-detect-module', additionalOptions: ['--experimental-detect-module'] },
788+
]) {
789+
it(testConfigName, async () => {
790+
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
791+
...additionalOptions,
792+
'--import',
793+
'../es-module-loaders/builtin-named-exports.mjs',
794+
fixtures.path('es-modules/require-esm-throws-with-loaders.js'),
795+
], {
796+
cwd: fixtures.path('es-modules'),
797+
});
798+
799+
assert.strictEqual(stderr, '');
800+
assert.strictEqual(stdout, '');
801+
assert.strictEqual(code, 0);
802+
assert.strictEqual(signal, null);
803+
});
804+
}
805+
});
806+
784807
it('should support source maps in commonjs translator', async () => {
785808
const readFile = async () => {};
786809
const hook = `

test/es-module/test-esm-named-exports-detect-module.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/es-module/test-esm-named-exports.js

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
const fixtures = require('../../common/fixtures');
3+
const { readFile, __fromLoader } = require('fs');
4+
const assert = require('assert');
5+
6+
const moduleName = fixtures.path('es-modules/test-esm-ok.mjs');
7+
assert.throws(() => require(moduleName), { code: 'ERR_REQUIRE_ESM' });
8+
9+
assert(readFile);
10+
assert(__fromLoader);

0 commit comments

Comments
 (0)