MCPcopy Create free account
hub / github.com/babel/babel / transform

Function transform

babel-worker.ts:30–51  ·  view source on GitHub ↗
(src: string, dest: string, opts: any = {})

Source from the content-addressed store, hash-verified

28}
29
30export async function transform(src: string, dest: string, opts: any = {}) {
31 mkdirSync(path.dirname(dest), { recursive: true });
32 if (!needCompile(src, dest)) {
33 return;
34 }
35 log(`Compiling '${styleText("cyan", src)}'...`);
36 const content = readFileSync(src, { encoding: "utf8" });
37 const { code } = (await transformAsync(content, {
38 filename: src,
39 sourceFileName: path.relative(path.dirname(dest), src),
40 caller: {
41 // We have wrapped packages/babel-core/src/config/files/configuration.js with feature detection
42 supportsDynamicImport: true,
43 name: "babel-worker",
44 },
45 ...opts,
46 }))!;
47
48 if (code) {
49 writeFileSync(dest, code, "utf8");
50 }
51}

Callers

nothing calls this directly

Calls 3

logFunction · 0.90
transformAsyncFunction · 0.90
needCompileFunction · 0.85

Tested by

no test coverage detected