Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 4x 4x 4x 4x 20x 20x | import type { Plugin } from "rollup";
import type { Options as SWCOptions } from "@swc/wasm-web";
import { merge } from "smob";
import type { Options } from "./type.js";
import { getSwc } from "./loadSwc.js";
export function swc(input: Options = {}): Plugin {
const defaults: SWCOptions = {
jsc: {
target: "es2020",
parser: {
syntax: "typescript",
decorators: true,
},
transform: {
decoratorMetadata: true,
legacyDecorator: true,
},
loose: true,
},
};
Iif (input.swc && input.swc.env) {
delete defaults.jsc?.target;
}
const swcOptions: SWCOptions = merge({}, input.swc || {}, defaults);
return {
name: "swc",
async transform(code, id) {
const { transform } = await getSwc();
return await transform(code, {
...swcOptions,
sourceMaps: true,
filename: id,
});
},
};
}
|