Skip to content

Commit

Permalink
fix: can't process side effect file on monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Sep 20, 2023
1 parent bcbbccc commit 076aff6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,26 @@ function handleOutputOption(conf: ResolvedConfig, outputs: Set<OutputOption>) {
// issue #39
// In some case like vite-plugin-legacy will set an empty output item
// we should skip it.

// Using full path. I find if we using like `dist` or others path it can't
// work on monorepo
// eg:
// yarn --cwd @pkg/website build
// At this time we will point to root directory. So that file with side effect
// can't process.
const prepareAbsPath = (root: string, sub: string) => path.resolve(root, sub)

if (conf.build.rollupOptions?.output) {
const outputOptions = Array.isArray(conf.build.rollupOptions.output)
? conf.build.rollupOptions.output
: [conf.build.rollupOptions.output]
outputOptions.forEach((opt) => {
if (typeof opt === 'object' && !len(Object.keys(opt))) return
outputs.add(opt.dir || conf.build.outDir)
outputs.add(prepareAbsPath(conf.root, opt.dir || conf.build.outDir))
})
return
}
outputs.add(conf.build.outDir)
outputs.add(prepareAbsPath(conf.root, conf.build.outDir))
}

function makeOutputs(outputs: Set<OutputOption>, file: string) {
Expand Down
3 changes: 2 additions & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export const tsup: Options = {
splitting: true,
clean: true,
shims: false,
minify: true
minify: true,
noExternal: ['@nolyfill/es-aggregate-error']
}

0 comments on commit 076aff6

Please sign in to comment.