@@ -144,6 +144,12 @@ export async function createEnvironmentPluginContainer(
144144 return container
145145}
146146
147+ export type SkipInformation = {
148+ id : string
149+ importer : string | undefined
150+ plugin : Plugin
151+ }
152+
147153class EnvironmentPluginContainer {
148154 private _pluginContextMap = new Map < Plugin , PluginContext > ( )
149155 private _resolvedRollupOptions ?: InputOptions
@@ -336,7 +342,9 @@ class EnvironmentPluginContainer {
336342 options ?: {
337343 attributes ?: Record < string , string >
338344 custom ?: CustomPluginOptions
345+ /** @deprecated use `skipCalls` instead */
339346 skip ?: Set < Plugin >
347+ skipCalls ?: readonly SkipInformation [ ]
340348 /**
341349 * @internal
342350 */
@@ -349,17 +357,25 @@ class EnvironmentPluginContainer {
349357 await this . _buildStartPromise
350358 }
351359 const skip = options ?. skip
360+ const skipCalls = options ?. skipCalls
352361 const scan = ! ! options ?. scan
353362 const ssr = this . environment . config . consumer === 'server'
354- const ctx = new ResolveIdContext ( this , skip , scan )
363+ const ctx = new ResolveIdContext ( this , skip , skipCalls , scan )
364+
365+ const mergedSkip = new Set < Plugin > ( skip )
366+ for ( const call of skipCalls ?? [ ] ) {
367+ if ( call . id === rawId && call . importer === importer ) {
368+ mergedSkip . add ( call . plugin )
369+ }
370+ }
355371
356372 const resolveStart = debugResolve ? performance . now ( ) : 0
357373 let id : string | null = null
358374 const partial : Partial < PartialResolvedId > = { }
359375 for ( const plugin of this . getSortedPlugins ( 'resolveId' ) ) {
360376 if ( this . _closed && this . environment . config . dev . recoverable )
361377 throwClosedServerError ( )
362- if ( skip ?. has ( plugin ) ) continue
378+ if ( mergedSkip ?. has ( plugin ) ) continue
363379
364380 ctx . _plugin = plugin
365381
@@ -534,6 +550,7 @@ class PluginContext implements Omit<RollupPluginContext, 'cache'> {
534550 _activeId : string | null = null
535551 _activeCode : string | null = null
536552 _resolveSkips ?: Set < Plugin >
553+ _resolveSkipCalls ?: readonly SkipInformation [ ]
537554 meta : RollupPluginContext [ 'meta' ]
538555 environment : Environment
539556
@@ -559,16 +576,19 @@ class PluginContext implements Omit<RollupPluginContext, 'cache'> {
559576 skipSelf ?: boolean
560577 } ,
561578 ) {
562- let skip : Set < Plugin > | undefined
563- if ( options ?. skipSelf !== false ) {
564- skip = new Set ( this . _resolveSkips )
565- skip . add ( this . _plugin )
566- }
579+ const skipCalls =
580+ options ?. skipSelf === false
581+ ? this . _resolveSkipCalls
582+ : [
583+ ...( this . _resolveSkipCalls || [ ] ) ,
584+ { id, importer, plugin : this . _plugin } ,
585+ ]
567586 let out = await this . _container . resolveId ( id , importer , {
568587 attributes : options ?. attributes ,
569588 custom : options ?. custom ,
570589 isEntry : ! ! options ?. isEntry ,
571- skip,
590+ skip : this . _resolveSkips ,
591+ skipCalls,
572592 scan : this . _scan ,
573593 } )
574594 if ( typeof out === 'string' ) out = { id : out }
@@ -794,10 +814,12 @@ class ResolveIdContext extends PluginContext {
794814 constructor (
795815 container : EnvironmentPluginContainer ,
796816 skip : Set < Plugin > | undefined ,
817+ skipCalls : readonly SkipInformation [ ] | undefined ,
797818 scan : boolean ,
798819 ) {
799820 super ( null ! , container )
800821 this . _resolveSkips = skip
822+ this . _resolveSkipCalls = skipCalls
801823 this . _scan = scan
802824 }
803825}
@@ -999,7 +1021,9 @@ class PluginContainer {
9991021 options ?: {
10001022 attributes ?: Record < string , string >
10011023 custom ?: CustomPluginOptions
1024+ /** @deprecated use `skipCalls` instead */
10021025 skip ?: Set < Plugin >
1026+ skipCalls ?: readonly SkipInformation [ ]
10031027 ssr ?: boolean
10041028 /**
10051029 * @internal
0 commit comments