mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
refactor: remove redundant comments and improve code clarity in build scripts
This commit is contained in:
1 parent
e8b01c357f
commit
eccea444b0
2 files changed
+5
-9
No files matched your search
@@ -21,7 +21,6 @@ async function buildI18n() {
|
||||
}
|
||||
fs.mkdirSync(distDir, { recursive: true })
|
||||
|
||||
// --- 1. 构建 global(.js) 到临时目录 ---
|
||||
const distJs = path.join(distDir, 'cjs')
|
||||
const bundlerJs = new Parcel({
|
||||
entries,
|
||||
@@ -39,7 +38,6 @@ async function buildI18n() {
|
||||
await bundlerJs.run()
|
||||
console.log('✅ Built i18n global (.js)')
|
||||
|
||||
// --- 2. 构建 esmodule(.mjs) 到临时目录 ---
|
||||
const distMjs = path.join(distDir, 'esm')
|
||||
const bundlerMjs = new Parcel({
|
||||
entries,
|
||||
@@ -66,7 +64,6 @@ async function buildI18n() {
|
||||
}
|
||||
console.log('✅ Built i18n esm (.mjs)')
|
||||
|
||||
// --- 3. 合并两个目录到 dist/i18n ---
|
||||
for (const f of fs.readdirSync(distJs)) {
|
||||
fs.renameSync(path.join(distJs, f), path.join(distDir, f))
|
||||
}
|
||||
|
||||
+5
-6
@@ -25,7 +25,6 @@ async function build(name, targetName, clean = false) {
|
||||
|
||||
const distDir = path.join(projects[name], 'dist')
|
||||
|
||||
// 👇 构建前清空 dist,只执行一次
|
||||
if (clean && fs.existsSync(distDir)) {
|
||||
fs.rmSync(distDir, { recursive: true, force: true })
|
||||
console.log(`🗑️ Cleaned ${distDir}`)
|
||||
@@ -65,9 +64,9 @@ async function build(name, targetName, clean = false) {
|
||||
}
|
||||
|
||||
const names = {
|
||||
main: `${name}.js`, // ✅ 保留 .js 后缀
|
||||
legacy: `${name}.legacy.js`, // ✅ 保留 .js 后缀
|
||||
esm: `${name}.mjs`, // ✅ ESM 用 .mjs
|
||||
main: `${name}.js`,
|
||||
legacy: `${name}.legacy.js`,
|
||||
esm: `${name}.mjs`,
|
||||
}
|
||||
|
||||
const entryFile = path.join(projects[name], 'src/index.js')
|
||||
@@ -116,7 +115,7 @@ async function build(name, targetName, clean = false) {
|
||||
async function runBuild() {
|
||||
if (process.argv.pop() === 'all') {
|
||||
const bundles = Object.keys(projects).map(name => async () => {
|
||||
await build(name, 'main', true) // 👈 第一次清理
|
||||
await build(name, 'main', true)
|
||||
await build(name, 'legacy')
|
||||
await build(name, 'esm')
|
||||
})
|
||||
@@ -137,7 +136,7 @@ async function runBuild() {
|
||||
})
|
||||
|
||||
if (response.value) {
|
||||
await build(response.value, 'main', true) // 👈 只清一次
|
||||
await build(response.value, 'main', true)
|
||||
await build(response.value, 'legacy')
|
||||
await build(response.value, 'esm')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user