Skip to content

Commit

Permalink
fix: don't transform to cjs twice, resolves #675
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Aug 12, 2022
1 parent c06b5e1 commit 7000c8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/esbuild/index.ts
Expand Up @@ -266,13 +266,13 @@ export async function runEsbuild(

// Manually write files
if (result && result.outputFiles) {
const timeInMs = Date.now() - startTime
logger.success(format, `⚡️ Build success in ${Math.floor(timeInMs)}ms`)

await pluginContainer.buildFinished({
outputFiles: result.outputFiles,
metafile: result.metafile,
})

const timeInMs = Date.now() - startTime
logger.success(format, `⚡️ Build success in ${Math.floor(timeInMs)}ms`)
}

if (result.metafile) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cjs-splitting.ts
@@ -1,7 +1,6 @@
// Workaround to enable code splitting for cjs format
// Manually transform esm to cjs
// TODO: remove this once esbuild supports code splitting for cjs natively
import path from 'path'
import { Plugin } from '../plugin'

export const cjsSplitting = (): Plugin => {
Expand All @@ -11,6 +10,7 @@ export const cjsSplitting = (): Plugin => {
async renderChunk(code, info) {
if (
!this.splitting ||
this.options.treeshake || // <-- handled by rollup
this.format !== 'cjs' ||
info.type !== 'chunk' ||
!/\.(js|cjs)$/.test(info.path)
Expand Down

1 comment on commit 7000c8b

@vercel
Copy link

@vercel vercel bot commented on 7000c8b Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.