build: build legacy target via Vite

This commit is contained in:
Amin Yahyaabadi 2024-09-04 01:27:11 -07:00
parent 8302e555d2
commit 1fab60e5ce
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
17 changed files with 43 additions and 1576 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/legacy/assets/hdi-Ca-ZsNp_.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,16 +26,16 @@
"tsconfig.json"
],
"scripts": {
"build": "turbo build && run-p lint.root.tsc build.parcel build.vite && run-p build.babel copy.json",
"build.parcel": "cross-env NODE_ENV=production parcel build",
"build": "turbo build && run-p lint.root.tsc build.vite build.vite.legacy && run-p build.babel copy.json",
"build.vite": "cross-env NODE_ENV=production vite build",
"build.babel": "babel ./dist/legacy --out-dir ./dist/legacy --plugins @upleveled/babel-plugin-remove-node-prefix --plugins @babel/plugin-transform-private-methods --compact --no-babelrc --source-maps true",
"build.vite.legacy": "cross-env NODE_ENV=production TARGET=legacy vite build",
"bump": "ncu -u -x numerous,execa,prettier,@types/node,eslint,@types/eslint && pnpm update && pnpx typesync && pnpm run clean",
"clean": "shx rm -rf ./dist ./packages/*/dist ./exe ./.parcel-cache && shx mkdir -p ./dist/legacy ./dist/modern ./dist/modern ",
"copy.json": "shx cp ./src/*/*.json ./dist/legacy/ && shx cp ./dist/legacy/*.json ./dist/modern",
"dev.parcel": "cross-env NODE_ENV=development parcel watch",
"dev.vite": "cross-env NODE_ENV=development vite build --watch",
"dev.packages": "turbo dev",
"dev": "run-p dev.packages dev.parcel",
"dev": "run-p dev.packages dev.vite",
"docs": "shx rm -rf packages/*/README.md && pnpm -r exec readme --path ../../dev/readme/template.md -y && pnpm -r exec ts-readme",
"format": "run-s lint.dprint",
"lint": "turbo lint && run-p --aggregate-output --continue-on-error lint.**",
@ -112,7 +112,6 @@
"npm-run-all2": "^6.2.2",
"numerous": "1.0.3",
"p-timeout": "^6.1.2",
"parcel": "2.12.0",
"path-exists": "^5.0.0",
"patha": "^0.4.1",
"prettier": "3.2.2",
@ -138,7 +137,6 @@
"untildify-user": "workspace:*",
"util.types": "^0.0.2",
"vite": "^5.4.3",
"vite-plugin-node": "^3.1.0",
"web-streams-polyfill": "^4.0.0",
"which": "^4.0.0"
},
@ -206,27 +204,6 @@
"ninja",
"meson"
],
"alias": {
"electron": false,
"patha": "patha/dist/index.node.mjs",
"admina": "admina/dist/index.mjs",
"fs/promises": "./src/utils/compat/fs/promises.ts",
"stream/promises": "./src/utils/compat/stream/promises.ts",
"stream/web": "web-streams-polyfill/dist/ponyfill.mjs",
"util/types": "util.types/index.js",
"diagnostics_channel": "diagnostics_channel/index.js"
},
"targets": {
"main": {
"context": "node",
"engines": {
"node": ">=12.x"
},
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
}
},
"pnpm": {
"patchedDependencies": {
"@actions/http-client@2.2.3": "patches/@actions__http-client@2.2.3.patch"

File diff suppressed because it is too large Load Diff

View File

@ -2,14 +2,36 @@ import module from "module"
import { type TerserOptions, defineConfig } from "vite"
import terserRc from "./.terserrc.mjs"
const isLegacy = process.env.TARGET === "legacy"
const viteConfig = defineConfig({
build: {
ssr: "./src/setup-cpp.ts",
outDir: "./dist/modern",
target: "node20",
outDir: isLegacy ? "./dist/legacy" : "./dist/modern",
target: isLegacy ? "node12" : "node20",
minify: "terser",
terserOptions: terserRc as TerserOptions,
sourcemap: true,
rollupOptions: {
output: {
format: isLegacy
? "cjs"
: "es",
},
},
},
resolve: {
alias: {
...(isLegacy
? {
"fs/promises": "./src/utils/compat/fs/promises.ts",
"stream/promises": "./src/utils/compat/stream/promises.ts",
"stream/web": "web-streams-polyfill/dist/ponyfill.mjs",
"util/types": "util.types/index.js",
diagnostics_channel: "diagnostics_channel/index.js",
}
: {}),
},
},
ssr: {
target: "node",