mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8c5c2c18b6
This reverts commit 22cb99d073
.
PR-URL: https://github.com/nodejs/node/pull/53183
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
31 lines
923 B
JavaScript
31 lines
923 B
JavaScript
import '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import { register } from 'node:module';
|
|
import assert from 'node:assert';
|
|
|
|
async function resolve(referrer, context, next) {
|
|
const result = await next(referrer, context);
|
|
const url = new URL(result.url);
|
|
url.searchParams.set('randomSeed', Math.random());
|
|
result.url = url.href;
|
|
return result;
|
|
}
|
|
|
|
function load(url, context, next) {
|
|
if (context.importAttributes.type === 'json') {
|
|
return {
|
|
shortCircuit: true,
|
|
format: 'json',
|
|
source: JSON.stringify({ data: Math.random() }),
|
|
};
|
|
}
|
|
return next(url, context);
|
|
}
|
|
|
|
register(`data:text/javascript,export ${encodeURIComponent(resolve)};export ${encodeURIComponent(load)}`);
|
|
|
|
assert.notDeepStrictEqual(
|
|
await import(fixtures.fileURL('empty.json'), { with: { type: 'json' } }),
|
|
await import(fixtures.fileURL('empty.json'), { with: { type: 'json' } }),
|
|
);
|