Debian Codegraph @

test/compiler-fixtures/esm-only-loader/esm-loader.fixture.mjs

raw symbols SCIP
1 import fsPromises from "node:fs/promises";
2 import { fileURLToPath } from "node:url";
3
4 export async function load(url, context, nextLoad) {
5 if (!url.includes("compiler-esm") && !url.includes("compiler-cjs")) {
6 return nextLoad(url, context);
7 }
8 const format = url.includes("compiler-esm") ? "module" : "commonjs";
9 const content = await fsPromises.readFile(
10 fileURLToPath(url + ".compiled"),
11 "utf8",
12 );
13 return {
14 format,
15 source: content,
16 shortCircuit: true,
17 };
18 }