mirror of
https://github.com/alex8088/electron-vite.git
synced 2025-11-10 06:24:33 +08:00
perf(bytecodePlugin): better way to count bytecode chunks
This commit is contained in:
parent
0fb8918090
commit
7587d2c674
@ -140,6 +140,8 @@ const bytecodeModuleLoaderCode = [
|
||||
`};`
|
||||
]
|
||||
|
||||
const bytecodeChunkExtensionRE = /.(jsc|cjsc)$/
|
||||
|
||||
export interface BytecodeOptions {
|
||||
chunkAlias?: string | string[]
|
||||
transformArrowFunctions?: boolean
|
||||
@ -180,8 +182,6 @@ export function bytecodePlugin(options: BytecodeOptions = {}): Plugin | null {
|
||||
return re ? { code: re.code || '', map: re.map } : null
|
||||
}
|
||||
|
||||
let bytecodeChunkCount = 0
|
||||
|
||||
const useStrict = '"use strict";'
|
||||
const bytecodeModuleLoader = 'bytecode-loader.cjs'
|
||||
|
||||
@ -248,6 +248,8 @@ export function bytecodePlugin(options: BytecodeOptions = {}): Plugin | null {
|
||||
return `require("${toRelativePath(bytecodeModuleLoader, normalizePath(chunkFileName))}");`
|
||||
}
|
||||
|
||||
let bytecodeChunkCount = 0
|
||||
|
||||
const bundles = Object.keys(output)
|
||||
|
||||
await Promise.all(
|
||||
@ -331,8 +333,9 @@ export function bytecodePlugin(options: BytecodeOptions = {}): Plugin | null {
|
||||
})
|
||||
}
|
||||
},
|
||||
writeBundle(): void {
|
||||
writeBundle(_, output): void {
|
||||
if (supported) {
|
||||
const bytecodeChunkCount = Object.keys(output).filter(chunk => bytecodeChunkExtensionRE.test(chunk)).length
|
||||
logger.info(`${colors.green(`✓`)} ${bytecodeChunkCount} chunks compiled into bytecode.`)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user