@@ -7,7 +7,11 @@ import { createBuilder } from '../build'
7
7
import { createServerModuleRunner } from '../ssr/runtime/serverModuleRunner'
8
8
9
9
describe ( 'custom environment conditions' , ( ) => {
10
- function getConfig ( ) : InlineConfig {
10
+ function getConfig ( {
11
+ noExternal,
12
+ } : {
13
+ noExternal : true | undefined
14
+ } ) : InlineConfig {
11
15
return {
12
16
configFile : false ,
13
17
root : import . meta. dirname ,
@@ -19,7 +23,7 @@ describe('custom environment conditions', () => {
19
23
// no web / default
20
24
ssr : {
21
25
resolve : {
22
- noExternal : true ,
26
+ noExternal,
23
27
} ,
24
28
build : {
25
29
outDir : path . join (
@@ -35,8 +39,9 @@ describe('custom environment conditions', () => {
35
39
worker : {
36
40
webCompatible : true ,
37
41
resolve : {
38
- noExternal : true ,
42
+ noExternal,
39
43
conditions : [ 'worker' ] ,
44
+ externalConditions : [ 'worker' ] ,
40
45
} ,
41
46
build : {
42
47
outDir : path . join (
@@ -52,8 +57,9 @@ describe('custom environment conditions', () => {
52
57
custom1 : {
53
58
webCompatible : true ,
54
59
resolve : {
55
- noExternal : true ,
60
+ noExternal,
56
61
conditions : [ 'custom1' ] ,
62
+ externalConditions : [ 'custom1' ] ,
57
63
} ,
58
64
build : {
59
65
outDir : path . join (
@@ -69,8 +75,9 @@ describe('custom environment conditions', () => {
69
75
custom2 : {
70
76
webCompatible : false ,
71
77
resolve : {
72
- noExternal : true ,
78
+ noExternal,
73
79
conditions : [ 'custom2' ] ,
80
+ externalConditions : [ 'custom2' ] ,
74
81
} ,
75
82
build : {
76
83
outDir : path . join (
@@ -86,8 +93,9 @@ describe('custom environment conditions', () => {
86
93
custom3 : {
87
94
webCompatible : false ,
88
95
resolve : {
89
- noExternal : true ,
96
+ noExternal,
90
97
conditions : [ 'custom3' ] ,
98
+ externalConditions : [ 'custom3' ] ,
91
99
} ,
92
100
build : {
93
101
outDir : path . join (
@@ -103,8 +111,9 @@ describe('custom environment conditions', () => {
103
111
custom3_2 : {
104
112
webCompatible : false ,
105
113
resolve : {
106
- noExternal : true ,
114
+ noExternal,
107
115
conditions : [ 'custom3' ] ,
116
+ externalConditions : [ 'custom3' ] ,
108
117
} ,
109
118
build : {
110
119
outDir : path . join (
@@ -120,8 +129,8 @@ describe('custom environment conditions', () => {
120
129
}
121
130
}
122
131
123
- test ( 'dev' , async ( ) => {
124
- const server = await createServer ( getConfig ( ) )
132
+ test ( 'dev noExternal ' , async ( ) => {
133
+ const server = await createServer ( getConfig ( { noExternal : true } ) )
125
134
onTestFinished ( ( ) => server . close ( ) )
126
135
127
136
const results : Record < string , unknown > = { }
@@ -154,8 +163,44 @@ describe('custom environment conditions', () => {
154
163
` )
155
164
} )
156
165
166
+ test ( 'dev external' , async ( ) => {
167
+ const server = await createServer ( getConfig ( { noExternal : undefined } ) )
168
+ onTestFinished ( ( ) => server . close ( ) )
169
+
170
+ const results : Record < string , unknown > = { }
171
+ for ( const key of [
172
+ 'ssr' ,
173
+ 'worker' ,
174
+ 'custom1' ,
175
+ 'custom2' ,
176
+ 'custom3' ,
177
+ 'custom3_2' ,
178
+ ] ) {
179
+ const runner = createServerModuleRunner ( server . environments [ key ] , {
180
+ hmr : {
181
+ logger : false ,
182
+ } ,
183
+ sourcemapInterceptor : false ,
184
+ } )
185
+ const mod = await runner . import (
186
+ '/fixtures/test-dep-conditions-app/entry.js' ,
187
+ )
188
+ results [ key ] = mod . default
189
+ }
190
+ expect ( results ) . toMatchInlineSnapshot ( `
191
+ {
192
+ "custom1": "index.custom1.js",
193
+ "custom2": "index.custom2.js",
194
+ "custom3": "index.custom3.js",
195
+ "custom3_2": "index.custom3.js",
196
+ "ssr": "index.default.js",
197
+ "worker": "index.worker.js",
198
+ }
199
+ ` )
200
+ } )
201
+
157
202
test ( 'css' , async ( ) => {
158
- const server = await createServer ( getConfig ( ) )
203
+ const server = await createServer ( getConfig ( { noExternal : true } ) )
159
204
onTestFinished ( ( ) => server . close ( ) )
160
205
161
206
const modJs = await server . ssrLoadModule (
@@ -174,7 +219,7 @@ describe('custom environment conditions', () => {
174
219
} )
175
220
176
221
test ( 'build' , async ( ) => {
177
- const builder = await createBuilder ( getConfig ( ) )
222
+ const builder = await createBuilder ( getConfig ( { noExternal : true } ) )
178
223
const results : Record < string , unknown > = { }
179
224
for ( const key of [
180
225
'ssr' ,
0 commit comments