build: use swc for TypeScript compilation

This commit is contained in:
Johannes Loher 2022-04-21 22:43:16 +02:00
parent 4a6a396445
commit 13586c532c
3 changed files with 270 additions and 70 deletions

View file

@ -3,9 +3,9 @@
// SPDX-License-Identifier: MIT
import copy from "@guanghechen/rollup-plugin-copy";
import typescript from "@rollup/plugin-typescript";
import styles from "rollup-plugin-styles";
import { terser } from "rollup-plugin-terser";
import { swc } from "rollup-plugin-swc3";
import { distDirectory, name, sourceDirectory } from "./tools/const.js";
import { convertJSONToPack } from "./tools/json-pack-tools.js";
@ -30,7 +30,7 @@ const isProduction = process.env.NODE_ENV === "production";
* @type {import('rollup').RollupOptions}
*/
const config = {
input: { [`${name}`]: `${sourceDirectory}/${name}.ts` },
input: { [name]: `${sourceDirectory}/${name}.ts` },
output: {
dir: distDirectory,
format: "es",
@ -38,7 +38,11 @@ const config = {
assetFileNames: "[name].[ext]",
},
plugins: [
typescript(),
swc({
minify: isProduction,
jsc: { minify: { sourceMap: true, keepFnames: true } },
sourceMaps: true,
}),
styles({
mode: ["extract", `css/${name}.css`],
url: false,
@ -60,8 +64,8 @@ const config = {
rename: (name, extension) => `${name.replace(".json", ".db")}.${extension}`,
},
],
verbose: true,
}),
isProduction && terser({ ecma: 2020, keep_fnames: true }),
],
};