File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,42 @@ describe('mergeConfig', () => {
189
189
expect ( mergeConfig ( newConfig , baseConfig ) ) . toEqual ( mergedConfig )
190
190
} )
191
191
192
+ test ( 'handles environments.*.resolve.noExternal' , ( ) => {
193
+ const baseConfig = {
194
+ environments : {
195
+ ssr : {
196
+ resolve : {
197
+ noExternal : true ,
198
+ } ,
199
+ } ,
200
+ } ,
201
+ }
202
+
203
+ const newConfig = {
204
+ environments : {
205
+ ssr : {
206
+ resolve : {
207
+ noExternal : [ 'foo' ] ,
208
+ } ,
209
+ } ,
210
+ } ,
211
+ }
212
+
213
+ const mergedConfig = {
214
+ environments : {
215
+ ssr : {
216
+ resolve : {
217
+ noExternal : true ,
218
+ } ,
219
+ } ,
220
+ } ,
221
+ }
222
+
223
+ // merging either ways, `resolve.noExternal: true` should take highest priority
224
+ expect ( mergeConfig ( baseConfig , newConfig ) ) . toEqual ( mergedConfig )
225
+ expect ( mergeConfig ( newConfig , baseConfig ) ) . toEqual ( mergedConfig )
226
+ } )
227
+
192
228
test ( 'handles server.hmr.server' , ( ) => {
193
229
const httpServer = http . createServer ( )
194
230
Original file line number Diff line number Diff line change @@ -1211,6 +1211,8 @@ function mergeWithDefaultsRecursively<
1211
1211
return merged as MergeWithDefaultsResult < D , V >
1212
1212
}
1213
1213
1214
+ const environmentPathRE = / ^ e n v i r o n m e n t s \. [ ^ . ] + $ /
1215
+
1214
1216
export function mergeWithDefaults <
1215
1217
D extends Record < string , any > ,
1216
1218
V extends Record < string , any > ,
@@ -1272,7 +1274,10 @@ function mergeConfigRecursively(
1272
1274
merged [ key ] = mergeConfigRecursively (
1273
1275
existing ,
1274
1276
value ,
1275
- rootPath ? `${ rootPath } .${ key } ` : key ,
1277
+ // treat environment.* as root
1278
+ rootPath && ! environmentPathRE . test ( rootPath )
1279
+ ? `${ rootPath } .${ key } `
1280
+ : key ,
1276
1281
)
1277
1282
continue
1278
1283
}
You can’t perform that action at this time.
0 commit comments