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 (#4643)
* Improve performance of chunk naming collision check * Improve coverage
- Loading branch information
1 parent
71d20c9
commit 7836357
Showing
10 changed files
with
105 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
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,15 @@ | ||
module.exports = { | ||
description: 'handles adding or deleting symbols in generateBundle', | ||
options: { | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
generateBundle(options, bundle) { | ||
const myKey = Symbol('test'); | ||
bundle[myKey] = 42; | ||
delete bundle[myKey]; | ||
} | ||
} | ||
] | ||
} | ||
}; |
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 @@ | ||
assert.ok(true); |