@@ -19,7 +19,7 @@ export default function (this: LoaderContext, source: string) {
1919 return source ;
2020}
2121
22- export async function pitch ( this : LoaderContext , remainingRequest : string ) {
22+ export function pitch ( this : LoaderContext ) {
2323 this . cacheable ( true ) ;
2424 const { childCompiler, outputCss } = loaderUtils . getOptions (
2525 this ,
@@ -33,49 +33,44 @@ export async function pitch(this: LoaderContext, remainingRequest: string) {
3333
3434 const isChildCompiler = childCompiler . isChildCompiler ( compiler . name ) ;
3535
36- if (
37- isChildCompiler &&
38- compiler . options . output . filename === this . resourcePath
39- ) {
36+ if ( isChildCompiler ) {
4037 log (
41- 'Skip vanilla-extract loader as we are already within a child compiler for this file' ,
38+ 'Skip vanilla-extract loader as we are already within a child compiler for %s' ,
39+ compiler . options . output . filename ,
4240 ) ;
4341 return ;
4442 }
4543
46- const callback = this . async ( ) ;
44+ log ( 'Loading file' ) ;
4745
48- try {
49- const { source } = await childCompiler . getCompiledSource (
50- this ,
51- remainingRequest ,
52- ) ;
46+ const callback = this . async ( ) ;
5347
54- if ( isChildCompiler ) {
55- // If within a vanilla-extract child compiler then only compile source, don't eval and assign CSS
56- return callback ( null , source ) ;
57- }
58-
59- const result = processVanillaFile ( {
60- source,
61- outputCss,
62- filePath : this . resourcePath ,
63- serializeVirtualCssPath : ( { fileName, base64Source } ) => {
64- const virtualResourceLoader = `${ require . resolve (
65- 'virtual-resource-loader' ,
66- ) } ?${ JSON . stringify ( { source : base64Source } ) } `;
67-
68- const request = loaderUtils . stringifyRequest (
69- this ,
70- `${ fileName } !=!${ virtualResourceLoader } !@vanilla-extract/webpack-plugin/extracted` ,
71- ) ;
72-
73- return `import ${ request } ` ;
74- } ,
48+ childCompiler
49+ . getCompiledSource ( this )
50+ . then ( ( { source } ) => {
51+ const result = processVanillaFile ( {
52+ source,
53+ outputCss,
54+ filePath : this . resourcePath ,
55+ serializeVirtualCssPath : ( { fileName, base64Source } ) => {
56+ const virtualResourceLoader = `${ require . resolve (
57+ 'virtual-resource-loader' ,
58+ ) } ?${ JSON . stringify ( { source : base64Source } ) } `;
59+
60+ const request = loaderUtils . stringifyRequest (
61+ this ,
62+ `${ fileName } !=!${ virtualResourceLoader } !@vanilla-extract/webpack-plugin/extracted` ,
63+ ) ;
64+
65+ return `import ${ request } ` ;
66+ } ,
67+ } ) ;
68+
69+ log ( 'Completed successfully' ) ;
70+
71+ callback ( null , result ) ;
72+ } )
73+ . catch ( ( e ) => {
74+ callback ( e ) ;
7575 } ) ;
76-
77- callback ( null , result ) ;
78- } catch ( e ) {
79- callback ( e ) ;
80- }
8176}
0 commit comments