Skip to content

Commit

Permalink
fix: fix treeshake sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
xia0hj authored and sxzz committed Jul 16, 2024
1 parent 580bcb8 commit 0b55771
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/tree-shaking.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { rollup, type TreeshakingOptions, type TreeshakingPreset } from 'rollup'
import type { Plugin } from '../plugin'
import path from 'path'

export type TreeshakingStrategy =
| boolean
Expand Down Expand Up @@ -44,14 +45,14 @@ export const treeShakingPlugin = ({
const result = await bundle.generate({
interop: 'auto',
format: this.format,
file: 'out.js',
file: info.path,
sourcemap: !!this.options.sourcemap,
name,
})

for (const file of result.output) {
if (file.type === 'chunk') {
if (file.fileName.endsWith('out.js')) {
if (file.fileName === path.basename(info.path)) {
return {
code: file.code,
map: file.map,
Expand Down

0 comments on commit 0b55771

Please sign in to comment.