Skip to content

Commit

Permalink
test resolve hook detected module type
Browse files Browse the repository at this point in the history
  • Loading branch information
dygabo committed Jun 24, 2024
1 parent 7964fe8 commit f4d6382
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/es-module/test-esm-detect-ambiguous.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ describe('--experimental-detect-module', { concurrency: !process.env.TEST_PARALL
], { cwd: fixtures.fileURL('es-module-loaders/') });

strictEqual(stderr, '');
strictEqual(stdout, 'commonjs\ntransformed!\n');
strictEqual(stdout, 'module\ncommonjs\ntransformed!\n');
strictEqual(code, 0);
strictEqual(signal, null);
});
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/es-module-loaders/transpile-esm-to-cjs.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import { writeSync } from "node:fs";

export async function resolve(specifier, context, next) {
const result = await next(specifier, context);
if (specifier.startsWith("file://")) {
writeSync(1, result.format + '\n');
}
return result;
}

export async function load(url, context, next) {
const output = await next(url, context);
let source = `${output.source}`
Expand Down

0 comments on commit f4d6382

Please sign in to comment.