@@ -4,7 +4,7 @@ import { composeAutoExternalConfig } from '../src/config';
44vi . mock ( 'rslog' ) ;
55
66describe ( 'should composeAutoExternalConfig correctly' , ( ) => {
7- it ( 'autoExternal is undefined ' , ( ) => {
7+ it ( 'autoExternal default value ' , ( ) => {
88 const esmResult = composeAutoExternalConfig ( {
99 format : 'esm' ,
1010 autoExternal : undefined ,
@@ -27,6 +27,28 @@ describe('should composeAutoExternalConfig correctly', () => {
2727 } ,
2828 } ) ;
2929
30+ const umdResult = composeAutoExternalConfig ( {
31+ format : 'umd' ,
32+ autoExternal : undefined ,
33+ pkgJson : {
34+ name : 'umd' ,
35+ dependencies : {
36+ foo : '1.0.0' ,
37+ } ,
38+ } ,
39+ } ) ;
40+
41+ const mfResult = composeAutoExternalConfig ( {
42+ format : 'mf' ,
43+ autoExternal : undefined ,
44+ pkgJson : {
45+ name : 'mf' ,
46+ dependencies : {
47+ foo : '1.0.0' ,
48+ } ,
49+ } ,
50+ } ) ;
51+
3052 expect ( esmResult ) . toMatchInlineSnapshot ( `
3153 {
3254 "output": {
@@ -48,33 +70,8 @@ describe('should composeAutoExternalConfig correctly', () => {
4870 },
4971 }
5072 ` ) ;
51- } ) ;
52-
53- it ( 'autoExternal should be disabled when format is umd or mf' , ( ) => {
54- const umdResult = composeAutoExternalConfig ( {
55- format : 'umd' ,
56- autoExternal : undefined ,
57- pkgJson : {
58- name : 'umd' ,
59- dependencies : {
60- foo : '1.0.0' ,
61- } ,
62- } ,
63- } ) ;
6473
6574 expect ( umdResult ) . toMatchInlineSnapshot ( '{}' ) ;
66-
67- const mfResult = composeAutoExternalConfig ( {
68- format : 'mf' ,
69- autoExternal : undefined ,
70- pkgJson : {
71- name : 'mf' ,
72- dependencies : {
73- foo : '1.0.0' ,
74- } ,
75- } ,
76- } ) ;
77-
7875 expect ( mfResult ) . toMatchInlineSnapshot ( '{}' ) ;
7976 } ) ;
8077
@@ -111,6 +108,52 @@ describe('should composeAutoExternalConfig correctly', () => {
111108 } ) ;
112109 } ) ;
113110
111+ it ( 'autoExternal is true when format is umd or mf' , ( ) => {
112+ const umdResult = composeAutoExternalConfig ( {
113+ format : 'umd' ,
114+ autoExternal : true ,
115+ pkgJson : {
116+ name : 'umd' ,
117+ dependencies : {
118+ foo : '1.0.0' ,
119+ } ,
120+ } ,
121+ } ) ;
122+
123+ expect ( umdResult ) . toMatchInlineSnapshot ( `
124+ {
125+ "output": {
126+ "externals": [
127+ /\\^foo\\(\\$\\|\\\\/\\|\\\\\\\\\\)/,
128+ "foo",
129+ ],
130+ },
131+ }
132+ ` ) ;
133+
134+ const mfResult = composeAutoExternalConfig ( {
135+ format : 'mf' ,
136+ autoExternal : true ,
137+ pkgJson : {
138+ name : 'mf' ,
139+ dependencies : {
140+ foo : '1.0.0' ,
141+ } ,
142+ } ,
143+ } ) ;
144+
145+ expect ( mfResult ) . toMatchInlineSnapshot ( `
146+ {
147+ "output": {
148+ "externals": [
149+ /\\^foo\\(\\$\\|\\\\/\\|\\\\\\\\\\)/,
150+ "foo",
151+ ],
152+ },
153+ }
154+ ` ) ;
155+ } ) ;
156+
114157 it ( 'autoExternal will deduplication ' , ( ) => {
115158 const result = composeAutoExternalConfig ( {
116159 format : 'esm' ,
0 commit comments