@@ -536,6 +536,7 @@ async function createProjectService(
536
536
let userPurge
537
537
let userVariants : any
538
538
let userMode : any
539
+ let userPlugins : any
539
540
let hook = new Hook ( fs . realpathSync ( state . configPath ) , ( exports ) => {
540
541
userSeperator = dlv ( exports , sepLocation )
541
542
if ( typeof userSeperator !== 'string' ) {
@@ -560,25 +561,33 @@ async function createProjectService(
560
561
561
562
// inject JIT `matchUtilities` function
562
563
if ( Array . isArray ( exports . plugins ) ) {
563
- for ( let index in exports . plugins ) {
564
- let plugin = exports . plugins [ index ]
564
+ userPlugins = exports . plugins
565
+ exports . plugins = exports . plugins . map ( ( plugin ) => {
565
566
if ( typeof plugin === 'function' ) {
566
- exports . plugins [ index ] = ( ...args ) => {
567
+ let newPlugin = ( ...args ) => {
567
568
if ( ! args [ 0 ] . matchUtilities ) {
568
569
args [ 0 ] . matchUtilities = ( ) => { }
569
570
}
570
571
return plugin ( ...args )
571
572
}
572
- } else if ( plugin . handler ) {
573
- let oldHandler = plugin . handler
574
- plugin . handler = ( ...args ) => {
575
- if ( ! args [ 0 ] . matchUtilities ) {
576
- args [ 0 ] . matchUtilities = ( ) => { }
577
- }
578
- return oldHandler ( ...args )
573
+ // @ts -ignore
574
+ newPlugin . __intellisense_cache_bust = Math . random ( )
575
+ return newPlugin
576
+ }
577
+ if ( plugin . handler ) {
578
+ return {
579
+ ...plugin ,
580
+ handler : ( ...args ) => {
581
+ if ( ! args [ 0 ] . matchUtilities ) {
582
+ args [ 0 ] . matchUtilities = ( ) => { }
583
+ }
584
+ return plugin . handler ( ...args )
585
+ } ,
586
+ __intellisense_cache_bust : Math . random ( ) ,
579
587
}
580
588
}
581
- }
589
+ return plugin
590
+ } )
582
591
}
583
592
584
593
return exports
@@ -640,6 +649,9 @@ async function createProjectService(
640
649
if ( typeof userMode !== 'undefined' ) {
641
650
config . mode = userMode
642
651
}
652
+ if ( typeof userPlugins !== 'undefined' ) {
653
+ config . plugins = userPlugins
654
+ }
643
655
644
656
if ( state . dependencies ) {
645
657
watcher . unwatch ( state . dependencies )
0 commit comments