Compare commits

...

3 Commits

Author SHA1 Message Date
Beans
7feae64e7e
Merge deed6f5891e20a26d4653323067576a7ce77a0c3 into 78a117d5be3c4696f3a90518a13dfad68d994ea4 2026-03-21 13:36:02 +01:00
alex8088
78a117d5be perf: build compatibility target for Electron 40, 41 2026-03-21 14:36:18 +08:00
leey0818
deed6f5891 feat(bytecode): support RegExp for chunkAlias option
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 13:44:03 +09:00
2 changed files with 10 additions and 4 deletions

View File

@ -69,6 +69,8 @@ export function getElectronNodeTarget(): string {
const electronVer = getElectronMajorVer()
const nodeVer = {
'41': '24.14',
'40': '24.14',
'39': '22.20',
'38': '22.19',
'37': '22.16',
@ -100,6 +102,8 @@ export function getElectronChromeTarget(): string {
const electronVer = getElectronMajorVer()
const chromeVer = {
'41': '146',
'40': '144',
'39': '142',
'38': '140',
'37': '138',

View File

@ -143,7 +143,7 @@ const bytecodeModuleLoaderCode = [
const bytecodeChunkExtensionRE = /.(jsc|cjsc)$/
export interface BytecodeOptions {
chunkAlias?: string | string[]
chunkAlias?: string | string[] | RegExp
transformArrowFunctions?: boolean
removeBundleJS?: boolean
protectedStrings?: string[]
@ -160,11 +160,13 @@ export function bytecodePlugin(options: BytecodeOptions = {}): Plugin | null {
}
const { chunkAlias = [], transformArrowFunctions = true, removeBundleJS = true, protectedStrings = [] } = options
const _chunkAlias = Array.isArray(chunkAlias) ? chunkAlias : [chunkAlias]
const _chunkAlias = chunkAlias instanceof RegExp ? chunkAlias : Array.isArray(chunkAlias) ? chunkAlias : [chunkAlias]
const transformAllChunks = _chunkAlias.length === 0
const isBytecodeChunk = (chunkName: string): boolean => {
return transformAllChunks || _chunkAlias.some(alias => alias === chunkName)
if (_chunkAlias instanceof RegExp) {
return _chunkAlias.test(chunkName)
}
return _chunkAlias.length === 0 || _chunkAlias.some(alias => alias === chunkName)
}
const plugins: babel.PluginItem[] = []