Skip to content

Commit c3d9d78

Browse files
authored
Remove unused webpack-plugin compiler cache (#260)
1 parent b31b0eb commit c3d9d78

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

.changeset/strong-coats-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vanilla-extract/webpack-plugin': patch
3+
---
4+
5+
Remove unused compiler cache

packages/webpack-plugin/src/compiler.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import type { LoaderContext } from './types';
22
import createCompat from './compat';
3-
import { debug } from './logger';
4-
5-
const log = debug('vanilla-extract:compiler');
63

74
// Should be "ExternalsItem" but webpack doesn't expose it
85
type Externals = any;
@@ -18,39 +15,20 @@ const getCompilerName = (resource: string) =>
1815

1916
export class ChildCompiler {
2017
externals: Externals | undefined;
21-
cache: Map<string, Promise<CompilationResult>>;
2218

2319
constructor(externals: Externals) {
24-
this.cache = new Map();
2520
this.externals = externals;
2621
}
2722

28-
clearCache() {
29-
log('Clearing child compiler cache');
30-
this.cache.clear();
31-
}
32-
3323
isChildCompiler(name: string | undefined) {
3424
return (
3525
typeof name === 'string' && name.startsWith('vanilla-extract-compiler')
3626
);
3727
}
3828

3929
async getCompiledSource(loader: LoaderContext) {
40-
const cacheId = loader.resourcePath;
41-
let compilationPromise = this.cache.get(cacheId);
42-
43-
if (!compilationPromise) {
44-
log('No cached compilation. Compiling: %s', cacheId);
45-
compilationPromise = compileVanillaSource(loader, this.externals);
46-
47-
this.cache.set(cacheId, compilationPromise);
48-
} else {
49-
log('Using cached compilation: %s', cacheId);
50-
}
51-
5230
const { source, fileDependencies, contextDependencies } =
53-
await compilationPromise;
31+
await compileVanillaSource(loader, this.externals);
5432

5533
// Set loader dependencies to dependencies of the child compiler
5634
fileDependencies.forEach((dep) => {

packages/webpack-plugin/src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ export class VanillaExtractPlugin {
9090
Boolean(compiler.webpack && compiler.webpack.version),
9191
);
9292

93-
compiler.hooks.watchRun.tap(pluginName, () => {
94-
this.childCompiler.clearCache();
95-
});
96-
9793
if (!compiler.parentCompilation && !this.allowRuntime) {
9894
compiler.hooks.compilation.tap(pluginName, (compilation) => {
9995
compilation.hooks.afterOptimizeModules.tap(pluginName, (modules) => {

0 commit comments

Comments
 (0)