Skip to content

Commit f584efb

Browse files
committed
fixup: rebase
1 parent 2ad8d50 commit f584efb

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

doc/api/esm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,11 @@ normally.
815815
816816
```js
817817
/**
818-
* This example causes
818+
* This example causes
819819
* @param {object} utilities
820820
* @param {MessagePort} utilities.port
821821
*/
822-
export function getGlobalPreloadCode({port}) {
822+
export function getGlobalPreloadCode({ port }) {
823823
port.onmessage = (evt) => {
824824
// ...
825825
};

lib/internal/modules/esm/initialize_import_meta.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
'use strict';
2+
13
const { getOptionValue } = require('internal/options');
24
const experimentalImportMetaResolve =
35
getOptionValue('--experimental-import-meta-resolve');
6+
const { PromisePrototypeThen, PromiseReject } = primordials;
7+
const asyncESM = require('internal/process/esm_loader');
48

59
function createImportMetaResolve(defaultParentUrl) {
610
return async function resolve(specifier, parentUrl = defaultParentUrl) {
7-
return PromisePrototypeCatch(
8-
asyncESM.ESMLoader.resolve(specifier, parentUrl),
11+
return PromisePrototypeThen(
12+
asyncESM.esmLoader.resolve(specifier, parentUrl),
13+
({ url }) => url,
914
(error) => (
1015
error.code === 'ERR_UNSUPPORTED_DIR_IMPORT' ?
1116
error.url : PromiseReject(error))

lib/internal/modules/esm/loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818
SafeWeakMap,
1919
globalThis,
2020
} = primordials;
21+
const { MessageChannel } = require('internal/worker/io');
2122

2223
const {
2324
ERR_INVALID_ARG_TYPE,
@@ -403,7 +404,7 @@ class ESMLoader {
403404
throw new ERR_INVALID_ARG_VALUE('builtinName', builtinName);
404405
}, insidePreload, (fn) => {
405406
if (finished || typeof fn !== 'function') {
406-
throw new ERR_INVALID_ARG_TYPE('fn', fn)
407+
throw new ERR_INVALID_ARG_TYPE('fn', fn);
407408
}
408409
replacedImportMetaInitializer = true;
409410
const parent = next;

lib/internal/modules/esm/translators.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const {
5050
const { maybeCacheSourceMap } = require('internal/source_map/source_map_cache');
5151
const moduleWrap = internalBinding('module_wrap');
5252
const { ModuleWrap } = moduleWrap;
53-
const { getOptionValue } = require('internal/options');
5453
const asyncESM = require('internal/process/esm_loader');
5554
const { emitWarningSync } = require('internal/process/warning');
5655
const { TextDecoder } = require('internal/encoding');

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Flags: --experimental-loader
2-
// ./test/fixtures/es-module-loaders/mock-loader.mjs
1+
// Flags: --loader ./test/fixtures/es-module-loaders/mock-loader.mjs
32
import '../common/index.mjs';
43
import assert from 'assert/strict';
54
import mock from 'node:mock';
@@ -8,7 +7,7 @@ mock('node:events', {
87
EventEmitter: 'This is mocked!'
98
});
109

11-
// this resolves to node:events
10+
// This resolves to node:events
1211
assert.deepStrictEqual(await import('events'), Object.defineProperty({
1312
__proto__: null,
1413
EventEmitter: 'This is mocked!'

test/parallel/test-bootstrap-modules.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const expectedModules = new Set([
7676
'NativeModule internal/modules/esm/module_job',
7777
'NativeModule internal/modules/esm/module_map',
7878
'NativeModule internal/modules/esm/resolve',
79+
'NativeModule internal/modules/esm/initialize_import_meta',
7980
'NativeModule internal/modules/esm/translators',
8081
'NativeModule internal/process/esm_loader',
8182
'NativeModule internal/options',

0 commit comments

Comments
 (0)