forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: deflake
test-esm-loader-resolve-type
PR-URL: nodejs#50273 Fixes: nodejs#50040 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
- Loading branch information
1 parent
d5b97ae
commit 53dd80c
Showing
2 changed files
with
23 additions
and
28 deletions.
There are no files selected for viewing
19 changes: 13 additions & 6 deletions
19
test/fixtures/es-module-loaders/hook-resolve-type-loader.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,18 @@ | ||
import * as fixtures from '../../common/fixtures.mjs'; | ||
import { register } from 'node:module'; | ||
import { MessageChannel } from 'node:worker_threads'; | ||
|
||
let importedESM = 0; | ||
let importedCJS = 0; | ||
const sab = new SharedArrayBuffer(2); | ||
const data = new Uint8Array(sab); | ||
|
||
const ESM_MODULE_INDEX = 0 | ||
const CJS_MODULE_INDEX = 1 | ||
|
||
export function getModuleTypeStats() { | ||
const importedESM = Atomics.load(data, ESM_MODULE_INDEX); | ||
const importedCJS = Atomics.load(data, CJS_MODULE_INDEX); | ||
return { importedESM, importedCJS }; | ||
}; | ||
|
||
const { port1, port2 } = new MessageChannel(); | ||
} | ||
|
||
register(fixtures.fileURL('es-module-loaders/hook-resolve-type-loader.mjs'), { | ||
data: { port: port2 }, | ||
transferList: [port2], | ||
data: { sab, ESM_MODULE_INDEX, CJS_MODULE_INDEX }, | ||
}); | ||
|
||
port1.on('message', ({ type }) => { | ||
switch (type) { | ||
case 'module': | ||
importedESM++; | ||
break; | ||
case 'commonjs': | ||
importedCJS++; | ||
break; | ||
} | ||
}); | ||
|
||
port1.unref(); | ||
port2.unref(); |