Skip to content

Commit 6f3bc8a

Browse files
committed
Use Set.difference
1 parent 4c75685 commit 6f3bc8a

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

packages/styles/src/build/private/injectCSSPlugin.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Metafile = {
3131
>;
3232
};
3333

34-
export function mapOutputsToRootOutputs(metafile: Metafile) {
34+
function mapOutputsToRootOutputs(metafile: Metafile) {
3535
const outputs = metafile.outputs || {};
3636
const allFiles = new Set(Object.keys(outputs));
3737

@@ -115,16 +115,6 @@ function findOutputKeyForFile(filePath: string, outputToRoots: Map<string, reado
115115
return undefined;
116116
}
117117

118-
function diffSets<K>(self: Set<K>, other: Set<K>): Set<K> {
119-
const result = new Set<K>();
120-
for (const element of self) {
121-
if (!other.has(element)) {
122-
result.add(element);
123-
}
124-
}
125-
return result;
126-
}
127-
128118
export default function injectCSSPlugin({ ignoreCSSEntries, stylesPlaceholder }: InjectCSSPluginOptions): Plugin {
129119
if (!stylesPlaceholder) {
130120
throw new Error('inject-css-plugin: no placeholder for styles provided');
@@ -186,7 +176,7 @@ export default function injectCSSPlugin({ ignoreCSSEntries, stylesPlaceholder }:
186176
.filter((entry): entry is readonly [string, OutputFile] => entry !== undefined)
187177
);
188178

189-
const cssCandidateKeys = diffSets(new Set(cssFilesMap.keys()), ignoreCSSEntriesSet);
179+
const cssCandidateKeys = new Set(cssFilesMap.keys()).difference(ignoreCSSEntriesSet);
190180

191181
if (cssCandidateKeys.size !== 1) {
192182
throw new Error(

0 commit comments

Comments
 (0)