Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance of chunk naming collision check
- Loading branch information
1 parent
71d20c9
commit 9fee6ab
Showing
8 changed files
with
89 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { OutputAsset, OutputBundle, OutputChunk } from '../rollup/types'; | ||
|
||
export const lowercaseBundleKeys = Symbol('bundleKeys'); | ||
|
||
export const FILE_PLACEHOLDER = { | ||
type: 'placeholder' as const | ||
}; | ||
|
||
export interface OutputBundleWithPlaceholders { | ||
[fileName: string]: OutputAsset | OutputChunk | typeof FILE_PLACEHOLDER; | ||
[lowercaseBundleKeys]: Set<string>; | ||
} | ||
|
||
export const getOutputBundle = (outputBundleBase: OutputBundle): OutputBundleWithPlaceholders => { | ||
const reservedLowercaseBundleKeys = new Set<string>(); | ||
return new Proxy(outputBundleBase, { | ||
deleteProperty(target, key) { | ||
if (typeof key === 'string') { | ||
reservedLowercaseBundleKeys.delete(key.toLowerCase()); | ||
} | ||
return Reflect.deleteProperty(target, key); | ||
}, | ||
get(target, key) { | ||
if (key === lowercaseBundleKeys) { | ||
return reservedLowercaseBundleKeys; | ||
} | ||
return Reflect.get(target, key); | ||
}, | ||
set(target, key, value) { | ||
if (typeof key === 'string') { | ||
reservedLowercaseBundleKeys.add(key.toLowerCase()); | ||
} | ||
return Reflect.set(target, key, value); | ||
} | ||
}) as OutputBundleWithPlaceholders; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters