Skip to content

Commit

Permalink
feat!: use .cjs extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 25, 2021
1 parent 1eab3d9 commit a1c8c0f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/builder/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function rollupBuild (ctx: BuildContext) {
if (ctx.stub) {
for (const entry of ctx.entries.filter(entry => entry.builder === 'rollup')) {
const output = resolve(ctx.rootDir, ctx.outDir, entry.name)
await writeFile(output + '.js', `module.exports = require('jiti')()('${entry.input}')`)
await writeFile(output + '.cjs', `module.exports = require('jiti')()('${entry.input}')`)
await writeFile(output + '.mjs', `export * from '${entry.input}'`)
await writeFile(output + '.d.ts', `export * from '${entry.input}'`)
}
Expand Down Expand Up @@ -59,7 +59,7 @@ export async function rollupBuild (ctx: BuildContext) {
}

export function getRollupOptions (ctx: BuildContext): RollupOptions {
const extensions = ['.ts', '.mjs', '.js', '.json']
const extensions = ['.ts', '.mjs', '.cjs', '.js', '.json']

return {
context: ctx.rootDir,
Expand All @@ -72,8 +72,8 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
output: [
{
dir: resolve(ctx.rootDir, ctx.outDir),
entryFileNames: '[name].js',
chunkFileNames: 'chunks/[name].js',
entryFileNames: '[name].cjs',
chunkFileNames: 'chunks/[name].cjs',
format: 'cjs',
exports: 'auto',
preferConst: true,
Expand Down

0 comments on commit a1c8c0f

Please sign in to comment.