1// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-side-effect.mjs --require ./test/fixtures/es-module-loaders/loader-side-effect-require-preload.js 2import { allowGlobals, mustCall } from '../common/index.mjs'; 3import assert from 'assert'; 4import { fileURLToPath } from 'url'; 5import { Worker, isMainThread, parentPort } from 'worker_threads'; 6 7/* global implicitGlobalProperty */ 8assert.strictEqual(globalThis.implicitGlobalProperty, 42); 9allowGlobals(implicitGlobalProperty); 10 11/* global implicitGlobalConst */ 12assert.strictEqual(implicitGlobalConst, 42 * 42); 13allowGlobals(implicitGlobalConst); 14 15/* global explicitGlobalProperty */ 16assert.strictEqual(globalThis.explicitGlobalProperty, 42 * 42 * 42); 17allowGlobals(explicitGlobalProperty); 18 19/* global preloadOrder */ 20assert.deepStrictEqual(globalThis.preloadOrder, ['--require', 'loader']); 21allowGlobals(preloadOrder); 22 23if (isMainThread) { 24 const worker = new Worker(fileURLToPath(import.meta.url)); 25 const promise = new Promise((resolve, reject) => { 26 worker.on('message', resolve); 27 worker.on('error', reject); 28 }); 29 promise.then(mustCall()); 30} else { 31 parentPort.postMessage('worker done'); 32} 33