Skip to content

Commit 420a7b4

Browse files
committed
fix: remove renaming of cjs files
1 parent f03cd16 commit 420a7b4

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

rollup.config.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { resolve, extname, dirname } from 'path';
1+
import { resolve, dirname } from 'path';
22
import { fileURLToPath } from 'url'
33

44
import pkg from './package.json' with { type: 'json' }
@@ -15,25 +15,6 @@ import { babel } from '@rollup/plugin-babel'
1515

1616
const __dirname = dirname(fileURLToPath(import.meta.url))
1717

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(/\.js$/, '.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-
3718
const baseConfig = {
3819
input: 'dist/esm-raw/index.js',
3920
output: {
@@ -86,8 +67,7 @@ const cjsConfig = {
8667
preventAssignment: true,
8768
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
8869
__VERSION__: JSON.stringify(pkg.version),
89-
}),
90-
renameJsToCjs()
70+
})
9171
],
9272
}
9373

0 commit comments

Comments
 (0)