8000 test: update ESM loader hooks to allow ambiguous format by avivkeller · Pull Request #52990 · nodejs/node · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions test/es-module/test-esm-loader-hooks.mjs
Original file line number Diff line number Diff line change
7E5C Expand Up @@ -751,15 +751,15 @@ describe('Loader hooks', { concurrency: !process.env.TEST_PARALLEL }, () => {
'--no-warnings',
'--experimental-loader',
`data:text/javascript,import{readFile}from"node:fs/promises";import{fileURLToPath}from"node:url";export ${
async function load(u, c, n) {
const r = await n(u, c);
if (u.endsWith('/common/index.js')) {
r.source = '"use strict";module.exports=require("node:module").createRequire(' +
`${JSON.stringify(u)})(${JSON.stringify(fileURLToPath(u))});\n`;
} else if (c.format === 'commonjs') {
r.source = await readFile(new URL(u));
async function load(url, context, nextLoad) {
const resolved = await nextLoad(url, context);
if (url.endsWith('/common/index.js')) {
resolved.source = '"use strict";module.exports=require("node:module").createRequire(' +
`${JSON.stringify(url)})(${JSON.stringify(fileURLToPath(url))});\n`;
} else if (context.format === 'commonjs' || context.format === null) {
resolved.source = await readFile(new URL(url));
}
return r;
return resolved;
}}`,
'--experimental-loader',
fixtures.fileURL('es-module-loaders/loader-resolve-passthru.mjs'),
Expand Down
0