@lynx-js/rspeedy
Version:
A webpack/rspack-based frontend toolchain for Lynx
26 lines (25 loc) • 1.32 kB
JavaScript
import { ES_ENV_TARGETS, getESVersionEnvInclude } from "./1~getESVersionTarget.js";
function pluginSwc() {
return {
name: 'lynx:rsbuild:swc',
setup (api) {
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
tools: {
swc (config) {
if (config.jsc?.target !== void 0) throw new Error(`Rspeedy manages the SWC compilation target via \`env\`, which is mutually exclusive with \`jsc.target\`. Remove \`tools.swc.jsc.target\` (received \`${JSON.stringify(config.jsc.target)}\`). To downlevel specific syntax, add the corresponding transforms to \`tools.swc.env.include\` instead (e.g. \`[\'transform-class-properties\']\`).`);
config.env = {
...config.env,
targets: ES_ENV_TARGETS,
include: [
'transform-block-scoping',
...getESVersionEnvInclude(),
...config.env?.include ?? []
]
};
}
}
}));
}
};
}
export { pluginSwc };