@@ -6,7 +6,7 @@ import { defineConfig, Plugin, RollupLog } from 'rollup'
66import typescript from '@rollup/plugin-typescript'
77import terser from '@rollup/plugin-terser'
88import fg from 'fast-glob'
9- import { basename , join } from 'path'
9+ import { basename , dirname , join } from 'path'
1010import { copyFileSync , opendirSync , rmSync , Dir } from 'fs'
1111import { fileURLToPath } from 'url'
1212
@@ -27,7 +27,7 @@ export default defineConfig([
2727 preserveModulesRoot : 'src' ,
2828 entryFileNames : ( chunkInfo ) => {
2929 if ( chunkInfo . name . includes ( 'node_modules' ) ) {
30- return chunkInfo . name . replace ( 'node_modules' , 'external' ) + '.js'
30+ return externalLibPath ( chunkInfo . name ) + '.js'
3131 }
3232
3333 return '[name].js'
@@ -40,7 +40,7 @@ export default defineConfig([
4040 preserveModulesRoot : 'src' ,
4141 entryFileNames : ( chunkInfo ) => {
4242 if ( chunkInfo . name . includes ( 'node_modules' ) ) {
43- return chunkInfo . name . replace ( 'node_modules' , 'external' ) + '.cjs'
43+ return externalLibPath ( chunkInfo . name ) + '.cjs'
4444 }
4545
4646 return '[name].cjs'
@@ -71,6 +71,10 @@ export default defineConfig([
7171 }
7272] )
7373
74+ function externalLibPath ( path : string ) {
75+ return `external/${ basename ( dirname ( path ) ) } /${ basename ( path ) } `
76+ }
77+
7478function onwarn ( warning : RollupLog ) {
7579 // deny warnings by default
7680 throw Object . assign ( new Error ( ) , warning )
0 commit comments