Skip to content

Commit

Permalink
feat: 引入基于 esbuild 的新型脚本编译器
Browse files Browse the repository at this point in the history
  • Loading branch information
zkz098 committed Sep 21, 2024
1 parent 0e6fadb commit 1143cde
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"eslint": "^9.11.0",
"eslint-config-standard": "~17",
"eslint-plugin-vue": "^9.28.0",
"glob": "^11.0.0",
"typescript": "^5.6.2"
},
"dependencies": {
Expand Down
19 changes: 17 additions & 2 deletions toolbox/compiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ compatibility: ShokaX v0.4.x
import path from "node:path";
import fs from 'fs/promises'
import child_process from 'child_process'
import { buildSync } from 'esbuild'
import { glob } from 'glob'

const CONFIG = {
legacyScript: true,
legacyScript: false,
}

async function deleteFileRecursive(dir) {
Expand Down Expand Up @@ -54,7 +56,20 @@ if (CONFIG.legacyScript) {
})
})
} else {
throw Error('Not implemented yet.')
console.log('RUN THIS SCRIPT IN YOUR SHOKAX THEME ROOT DIRECTORY!')
console.log('Using esbuild compiler...')
const entryPoints = glob.sync('./scripts/**/*.ts');
buildSync({
entryPoints: entryPoints,
outdir: 'scripts',
bundle: false,
format: 'cjs',
target: ['esnext'],
platform: 'node',
loader: { '.ts': 'ts' },
})
await deleteFileRecursive('./scripts/')
console.log('Finished compiling.')
}

console.log('Done.')
Expand Down

0 comments on commit 1143cde

Please sign in to comment.