@@ -15,19 +15,36 @@ const rules = [].concat(
1515 {
1616 test : / \. j s $ / ,
1717 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 /
1919 }
2020)
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+ }
2240module . exports = {
2341 module : {
2442 rules
2543 } ,
26- externals : ! browser ? [ nodeExternals ( ) ] : undefined ,
44+ externals : ! browser ? [ externals ] : undefined ,
2745 resolve : {
2846 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 ,
3148 '~resources' : `${ projectRoot } /test/resources`
3249 }
3350 } ,
0 commit comments