1
- import { resolve , extname , dirname } from 'path' ;
1
+ import { resolve , dirname } from 'path' ;
2
2
import { fileURLToPath } from 'url'
3
3
4
4
import pkg from './package.json' with { type : 'json' }
@@ -15,25 +15,6 @@ import { babel } from '@rollup/plugin-babel'
15
15
16
16
const __dirname = dirname ( fileURLToPath ( import . meta. url ) )
17
17
18
- function renameJsToCjs ( ) {
19
- return {
20
- name : 'rename-js-to-cjs' ,
21
- generateBundle ( options , bundle ) {
22
- for ( const [ fileName , file ] of Object . entries ( bundle ) ) {
23
- if ( file . type === 'chunk' && extname ( fileName ) === '.js' ) {
24
- const newFileName = fileName . replace ( / \. j s $ / , '.cjs' ) ;
25
-
26
- // Emit new file with updated name and same code
27
- this . emitFile ( { type : 'asset' , fileName : newFileName , source : file . code } ) ;
28
-
29
- // Remove old .js entry
30
- delete bundle [ fileName ] ;
31
- }
32
- }
33
- } ,
34
- } ;
35
- }
36
-
37
18
const baseConfig = {
38
19
input : 'dist/esm-raw/index.js' ,
39
20
output : {
@@ -86,8 +67,7 @@ const cjsConfig = {
86
67
preventAssignment : true ,
87
68
'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) ,
88
69
__VERSION__ : JSON . stringify ( pkg . version ) ,
89
- } ) ,
90
- renameJsToCjs ( )
70
+ } )
91
71
] ,
92
72
}
93
73
0 commit comments