@@ -12,6 +12,7 @@ import { isSourceCandidateRequest } from '../source-candidates'
1212import { cleanUrl , isCSSRequest } from '../utils'
1313
1414export function createFrameworkSourceCandidatesPlugin ( options : any , apply ?: Plugin [ 'apply' ] ) : Plugin {
15+ const shouldSkipSourceCandidateState = ( ) => options . shouldSkipSourceCandidateState ?.( ) === true
1516 const hasDifferentHotModules = ( left : ModuleNode [ ] , right : ModuleNode [ ] ) => left . length !== right . length
1617 || left . some ( ( mod , index ) => mod !== right [ index ] )
1718 const hasTemplateHotSourceModule = ( modules : Array < { id ?: string | null , url ?: string | null } > ) => modules . some ( ( mod ) => {
@@ -51,6 +52,7 @@ export function createFrameworkSourceCandidatesPlugin(options: any, apply?: Plug
5152 async load ( id ) {
5253 if (
5354 ! options . shouldOwnTailwindGeneration
55+ || shouldSkipSourceCandidateState ( )
5456 || options . isWebOrNativeAppPlatform ( options . resolveViteStylePlatform ( ) )
5557 || ! isCSSRequest ( id )
5658 || ! shouldCollectTransformedSourceCandidates ( id )
@@ -73,6 +75,9 @@ export function createFrameworkSourceCandidatesPlugin(options: any, apply?: Plug
7375 transform : {
7476 order : 'pre' ,
7577 async handler ( code , id ) {
78+ if ( shouldSkipSourceCandidateState ( ) ) {
79+ return
80+ }
7681 if ( options . hasUserCssLayerBlocks ( code ) ) {
7782 options . rememberOriginalCssLayerSource ( id , code )
7883 }
@@ -87,7 +92,7 @@ export function createFrameworkSourceCandidatesPlugin(options: any, apply?: Plug
8792 options . rememberTailwindRootCssModule ( id )
8893 }
8994 }
90- if ( ! options . shouldOwnTailwindGeneration || options . collectSourceCandidates === false || ! isSourceCandidateRequest ( id ) || ! shouldCollectTransformedSourceCandidates ( id ) ) {
95+ if ( ! options . shouldOwnTailwindGeneration || shouldSkipSourceCandidateState ( ) || options . collectSourceCandidates === false || ! isSourceCandidateRequest ( id ) || ! shouldCollectTransformedSourceCandidates ( id ) ) {
9196 return shouldReturnTransformedCode ? { code : transformedCode , map : null } : undefined
9297 }
9398 return options . hmrTimingRecorder . measure ( 'sourceCandidates.transform' , async ( ) => {
@@ -105,6 +110,9 @@ export function createFrameworkSourceCandidatesPlugin(options: any, apply?: Plug
105110 } ,
106111 } ,
107112 async watchChange ( id , change ) {
113+ if ( shouldSkipSourceCandidateState ( ) ) {
114+ return
115+ }
108116 recordCompilationDependencyChanges ( options . runtimeState , createCompilationDependencyChanges ( [ path . resolve ( cleanUrl ( id ) ) ] ) )
109117 await options . hmrTimingRecorder . measure ( 'sourceCandidates.watchChange' , async ( ) => {
110118 if ( options . shouldOwnTailwindGeneration && options . collectSourceCandidates !== false && isSourceCandidateRequest ( id ) ) {
@@ -147,6 +155,9 @@ export function createFrameworkSourceCandidatesPlugin(options: any, apply?: Plug
147155 handleHotUpdate : {
148156 order : 'post' ,
149157 async handler ( ctx ) {
158+ if ( shouldSkipSourceCandidateState ( ) ) {
159+ return
160+ }
150161 recordCompilationDependencyChanges ( options . runtimeState , createCompilationDependencyChanges ( [ path . resolve ( cleanUrl ( ctx . file ) ) ] ) )
151162 return options . hmrTimingRecorder . measure ( 'sourceCandidates.handleHotUpdate' , async ( ) => {
152163 const isSourceCandidateHotUpdate = options . shouldOwnTailwindGeneration && options . collectSourceCandidates !== false && isSourceCandidateRequest ( ctx . file )
@@ -307,8 +318,16 @@ export function createFrameworkSourceCandidatesPlugin(options: any, apply?: Plug
307318 options . hmrCssModuleVersions ?. clear ( )
308319 } ,
309320 async buildStart ( ) {
321+ if ( shouldSkipSourceCandidateState ( ) ) {
322+ return
323+ }
310324 await options . hmrTimingRecorder . measure ( 'sourceCandidates.buildStart' , options . prepareTailwindGeneration , { emit : false } )
311325 } ,
312- generateBundle : options . preGenerateBundleHook ,
326+ async generateBundle ( ...args : any [ ] ) {
327+ if ( shouldSkipSourceCandidateState ( ) ) {
328+ return
329+ }
330+ return options . preGenerateBundleHook ?. apply ( this , args )
331+ } ,
313332 }
314333}
0 commit comments