@@ -19,14 +19,29 @@ const EXTERNAL_PATHS = [
19
19
'echarts-for-react/lib/core' ,
20
20
'/node_modules/echarts' ,
21
21
'/node_modules/dayjs' ,
22
- ] ;
23
- const DEPENDENCIES = new Set ( Object . keys ( dependencies ) . concat ( Object . keys ( peerDependencies ) ) ) ;
24
- const externals = ( id : string , importer : any , isResolved : boolean ) => {
22
+ / ^ d a y j s \/ p l u g i n / ,
23
+ / ^ d a y j s $ / ,
25
24
// babel transforms module id of emotion, we need to exclude all of them
26
- if ( id . startsWith ( '@emotion' ) ) {
27
- return true ;
25
+ / ^ @ e m o t i o n / ,
26
+ ] ;
27
+
28
+ function shouldExternalize ( id : string ) {
29
+ // check id against external paths
30
+ for ( const path of EXTERNAL_PATHS ) {
31
+ if ( typeof path === 'string' ) {
32
+ if ( id . includes ( path ) ) {
33
+ return true ;
34
+ }
35
+ } else if ( path . test ( id ) ) {
36
+ return true ;
37
+ }
28
38
}
29
- if ( EXTERNAL_PATHS . some ( ( p ) => id . includes ( p ) ) ) {
39
+ return false ;
40
+ }
41
+
42
+ const DEPENDENCIES = new Set ( Object . keys ( dependencies ) . concat ( Object . keys ( peerDependencies ) ) ) ;
43
+ const externals = ( id : string ) => {
44
+ if ( shouldExternalize ( id ) ) {
30
45
return true ;
31
46
}
32
47
return DEPENDENCIES . has ( id ) ;
@@ -61,7 +76,6 @@ export default defineConfig({
61
76
react : 'react' ,
62
77
'react/jsx-runtime.js' : 'react/jsx-runtime.js' ,
63
78
'reactflow/dist/style.css' : 'reactflow/dist/style.css' ,
64
- 'dayjs/plugin' : 'dayjs/plugin' ,
65
79
} ,
66
80
} ,
67
81
build : {
@@ -80,7 +94,9 @@ export default defineConfig({
80
94
const ret = GLOBAL_MODULE_IDS [ name ] ;
81
95
return ret ?? name ;
82
96
}
83
- const match = EXTERNAL_PATHS . find ( ( p ) => name . includes ( p ) ) ;
97
+ const match = ( EXTERNAL_PATHS . filter ( ( it ) => typeof it === 'string' ) as string [ ] ) . find ( ( p ) =>
98
+ name . includes ( p ) ,
99
+ ) ;
84
100
if ( match ) {
85
101
return match . replace ( '/node_modules/' , '' ) ;
86
102
}
0 commit comments