diff --git a/build.mjs b/build.mjs index 47b462b..1ef73c9 100644 --- a/build.mjs +++ b/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 }), ] }; diff --git a/package.json b/package.json index ea2cfb7..82e6bb5 100644 --- a/package.json +++ b/package.json @@ -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" } }