fix: Android 上強制使用 @rollup/wasm-node
This commit is contained in:
36
client/checkIsAndroidAndBuild.ts
Normal file
36
client/checkIsAndroidAndBuild.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import process from 'node:process'
|
||||||
|
import child_process from 'node:child_process'
|
||||||
|
import fs from 'node:fs/promises'
|
||||||
|
|
||||||
|
function spawn(exec: string, args: string[]) {
|
||||||
|
child_process.spawnSync(exec, args, {
|
||||||
|
stdio: [process.stdin, process.stdout, process.stderr]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function runBuild() {
|
||||||
|
const args = [
|
||||||
|
"run",
|
||||||
|
"-A",
|
||||||
|
"--node-modules-dir",
|
||||||
|
]
|
||||||
|
let i = 0
|
||||||
|
for (const arg of process.argv) {
|
||||||
|
if (i > 1)
|
||||||
|
args.push(arg)
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
spawn('deno', args)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform == 'android') {
|
||||||
|
try {
|
||||||
|
await fs.stat('./node_modules/.deno/rollup@4.50.1/node_modules/rollup/')
|
||||||
|
} catch (e) {
|
||||||
|
spawn('deno', ['install', '--node-modules-dir=auto'])
|
||||||
|
}
|
||||||
|
spawn('sh', ["fix-build-on-android.sh"])
|
||||||
|
}
|
||||||
|
|
||||||
|
runBuild()
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"build": "deno run -A --node-modules-dir npm:vite build",
|
"build": "deno run --allow-run --allow-env --allow-read checkIsAndroidAndBuild.ts npm:vite build",
|
||||||
"build-watch": "deno run -A --node-modules-dir npm:vite --watch build"
|
"build-watch": "deno run --allow-run --allow-env --allow-read checkIsAndroidAndBuild.ts npm:vite --watch build"
|
||||||
},
|
},
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
"react": "npm:react@18.3.1",
|
"react": "npm:react@18.3.1",
|
||||||
"react-dom": "npm:react-dom@18.3.1",
|
"react-dom": "npm:react-dom@18.3.1",
|
||||||
"vite": "npm:vite@7.0.6",
|
"vite": "npm:vite@7.0.6",
|
||||||
|
|
||||||
|
"rollup": "npm:@rollup/wasm-node@4.48.0",
|
||||||
|
|
||||||
"chalk": "npm:chalk@5.4.1",
|
"chalk": "npm:chalk@5.4.1",
|
||||||
|
|
||||||
|
|||||||
3
client/fix-build-on-android.sh
Normal file
3
client/fix-build-on-android.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
rm -r ./node_modules/.deno/rollup@4.50.1/node_modules/rollup/
|
||||||
|
cp -r ./node_modules/.deno/@rollup+wasm-node@4.48.0/node_modules/@rollup/wasm-node/ node_modules/.deno/rollup@4.50.1/node_modules/rollup/
|
||||||
|
echo Replaced rollup with @rollup/wasm-node successfully
|
||||||
Reference in New Issue
Block a user