transform with swc, resolve/minify with esbuild
This commit is contained in:
parent
62bf863d1c
commit
b84db804ad
2 changed files with 32 additions and 12 deletions
38
build.mjs
38
build.mjs
|
|
@ -6,7 +6,8 @@ import { readdirSync, readFileSync, writeFileSync } from "fs";
|
|||
import { argv } from "process";
|
||||
import { rollup, watch } from "rollup";
|
||||
|
||||
const swc = (await import("@aliucord/rollup-plugin-swc")).default.default;
|
||||
import swc from "@swc/core";
|
||||
import esbuild from "rollup-plugin-esbuild";
|
||||
|
||||
const args = argv.slice(2);
|
||||
console.clear();
|
||||
|
|
@ -49,7 +50,9 @@ async function buildPlugin(plugin) {
|
|||
output: {
|
||||
file: outPath,
|
||||
globals(id) {
|
||||
if (id.startsWith("@vendetta")) return id.substring(1).replace(/\//g, ".");
|
||||
if (id.startsWith("@vendetta"))
|
||||
return id.substring(1).replace(/\//g, ".");
|
||||
|
||||
const map = {
|
||||
react: "window.React"
|
||||
};
|
||||
|
|
@ -70,16 +73,29 @@ async function buildPlugin(plugin) {
|
|||
plugins: [
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
swc({
|
||||
env: {
|
||||
targets: "defaults",
|
||||
include: [
|
||||
"transform-classes",
|
||||
"transform-arrow-functions",
|
||||
]
|
||||
{
|
||||
name: "swc",
|
||||
transform(code, id) {
|
||||
return swc.transform(code, {
|
||||
filename: id,
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: "typescript",
|
||||
tsx: true,
|
||||
},
|
||||
externalHelpers: true,
|
||||
},
|
||||
env: {
|
||||
targets: "defaults",
|
||||
include: [
|
||||
"transform-classes",
|
||||
"transform-arrow-functions",
|
||||
],
|
||||
},
|
||||
});
|
||||
},
|
||||
minify: true
|
||||
})
|
||||
},
|
||||
esbuild({ minify: true }),
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
"lint": "eslint plugins"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@aliucord/rollup-plugin-swc": "^0.2.2",
|
||||
"@rollup/plugin-commonjs": "^24.0.1",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@swc/core": "^1.3.36",
|
||||
|
|
@ -12,10 +11,15 @@
|
|||
"@types/react-native": "^0.70.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.53.0",
|
||||
"@typescript-eslint/parser": "^5.53.0",
|
||||
"esbuild": "^0.17.11",
|
||||
"eslint": "^8.35.0",
|
||||
"eslint-plugin-react": "^7.32.2",
|
||||
"rollup": "^3.17.3",
|
||||
"rollup-plugin-esbuild": "^5.0.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vendetta-types": "^2.3.16"
|
||||
},
|
||||
"dependencies": {
|
||||
"@swc/helpers": "^0.4.14"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue