@@ -11,7 +11,7 @@ import path from 'path'
1111import resolve from 'resolve'
1212
1313// Local Imports
14- import { buildCandidatePaths , getPackageName } from '../../shared/utils'
14+ import { buildCandidatePaths , getPackageName , SETUP_FILE_REGEX } from '../../shared/utils'
1515
1616// Types
1717import type { ExtendedCompiler } from './types'
@@ -23,6 +23,12 @@ const OVERRIDABLE_FILE_NAME = '.force_overrides'
2323const REQUIRES_REGEX = / r e q u i r e \( [ ' " ] ( \. .* ?) [ ' " ] \) / g
2424const SRC = 'src'
2525
26+ // Cache for processed overrides
27+ const OVERRIDABLE_CACHE = {
28+ node : [ ] as string [ ] ,
29+ web : [ ] as string [ ]
30+ }
31+
2632/**
2733 * Webpack loader to override the resolution of a module based on the PWA-Kit applications
2834 * extension configuration.
@@ -118,11 +124,6 @@ const OverrideResolverLoader = function (this: LoaderContext<any>) {
118124 } )
119125}
120126
121- const OVERRIDABLE_CACHE = {
122- node : [ ] as string [ ] ,
123- web : [ ] as string [ ]
124- }
125-
126127/**
127128 *
128129 * @param {* } source
@@ -133,13 +134,14 @@ const validateOverrideSource = (source: string, options: any = {}) => {
133134 const { target = 'node' , overridables = [ ] } = options
134135 const isMonoRepo = true
135136 const isExtensionFile = source . includes ( `${ path . sep } ${ EXTENSION_PACKAGE_PREFIX } ` )
137+ const isSetupFile = SETUP_FILE_REGEX . test ( source )
136138 const targetCache = OVERRIDABLE_CACHE [ target as keyof typeof OVERRIDABLE_CACHE ]
137139
138140 // Exit early if we have:
139141 // 1. Processed this file already.
140142 // 2. The file is not an extension file.
141- // 3. TBD - The file is in the disallowed list .
142- if ( targetCache . includes ( source ) || ! isExtensionFile ) {
143+ // 3. The file is an extension setup file .
144+ if ( targetCache . includes ( source ) || ! isExtensionFile || isSetupFile ) {
143145 return false
144146 }
145147
0 commit comments