@@ -6,7 +6,7 @@ import { defineConfig, Plugin, RollupLog } from 'rollup'
6
6
import typescript from '@rollup/plugin-typescript'
7
7
import terser from '@rollup/plugin-terser'
8
8
import fg from 'fast-glob'
9
- import { basename , join } from 'path'
9
+ import { basename , dirname , join } from 'path'
10
10
import { copyFileSync , opendirSync , rmSync , Dir } from 'fs'
11
11
import { fileURLToPath } from 'url'
12
12
@@ -27,7 +27,7 @@ export default defineConfig([
27
27
preserveModulesRoot : 'src' ,
28
28
entryFileNames : ( chunkInfo ) => {
29
29
if ( chunkInfo . name . includes ( 'node_modules' ) ) {
30
- return chunkInfo . name . replace ( 'node_modules' , 'external' ) + '.js'
30
+ return externalLibPath ( chunkInfo . name ) + '.js'
31
31
}
32
32
33
33
return '[name].js'
@@ -40,7 +40,7 @@ export default defineConfig([
40
40
preserveModulesRoot : 'src' ,
41
41
entryFileNames : ( chunkInfo ) => {
42
42
if ( chunkInfo . name . includes ( 'node_modules' ) ) {
43
- return chunkInfo . name . replace ( 'node_modules' , 'external' ) + '.cjs'
43
+ return externalLibPath ( chunkInfo . name ) + '.cjs'
44
44
}
45
45
46
46
return '[name].cjs'
@@ -71,6 +71,10 @@ export default defineConfig([
71
71
}
72
72
] )
73
73
74
+ function externalLibPath ( path : string ) {
75
+ return `external/${ basename ( dirname ( path ) ) } /${ basename ( path ) } `
76
+ }
77
+
74
78
function onwarn ( warning : RollupLog ) {
75
79
// deny warnings by default
76
80
throw Object . assign ( new Error ( ) , warning )
0 commit comments