@@ -15,19 +15,36 @@ const rules = [].concat(
15
15
{
16
16
test : / \. j s $ / ,
17
17
loader : 'babel-loader' ,
18
- exclude : / n o d e _ m o d u l e s \/ (? ! ( s h a r e d | c r e a t e - i n s t a n c e ) \/ ) . * /
18
+ exclude : / n o d e _ m o d u l e s /
19
19
}
20
20
)
21
-
21
+ const externals = nodeExternals ( {
22
+ // we need to whitelist both `create-instance` and files in `shared` package. Otherwise Webpack wont bundle them in the test dev env
23
+ whitelist : [ 'create-instance' , / ^ s h a r e d \/ .* / ]
24
+ } )
25
+ // define the default aliases
26
+ let aliasedFiles = {
27
+ '~vue/server-test-utils' : `@vue/server-test-utils` ,
28
+ '~vue/test-utils' : `@vue/test-utils`
29
+ }
30
+ if ( process . env . TARGET === 'dev' ) {
31
+ // if we are in dev test mode, we want to alias all files to the src file, not dist
32
+ aliasedFiles = {
33
+ // we need both as some places import the old alias with ~, others directly test utils package.
34
+ '@vue/server-test-utils' : `@vue/server-test-utils/src/index.js` ,
35
+ '@vue/test-utils' : `@vue/test-utils/src/index.js` ,
36
+ '~vue/server-test-utils' : `@vue/server-test-utils/src/index.js` ,
37
+ '~vue/test-utils' : `@vue/test-utils/src/index.js`
38
+ }
39
+ }
22
40
module . exports = {
23
41
module : {
24
42
rules
25
43
} ,
26
- externals : ! browser ? [ nodeExternals ( ) ] : undefined ,
44
+ externals : ! browser ? [ externals ] : undefined ,
27
45
resolve : {
28
46
alias : {
29
- '~vue/server-test-utils' : `${ projectRoot } /packages/server-test-utils/dist/vue-server-test-utils.js` ,
30
- '~vue/test-utils' : `${ projectRoot } /packages/test-utils/dist/vue-test-utils.js` ,
47
+ ...aliasedFiles ,
31
48
'~resources' : `${ projectRoot } /test/resources`
32
49
}
33
50
} ,
0 commit comments