(src: string, dest: string, opts: any = {})
| 28 | } |
| 29 | |
| 30 | export 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 | } |
nothing calls this directly
no test coverage detected