11import type { LoaderContext } from './types' ;
22import 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
85type Externals = any ;
@@ -18,39 +15,20 @@ const getCompilerName = (resource: string) =>
1815
1916export 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 ) => {
0 commit comments