Skip to content

Commit

Permalink
fix: default sideEffect option is delivered to rollup (#15665)
Browse files Browse the repository at this point in the history
  • Loading branch information
XiSenao authored Jan 22, 2024
1 parent a6f39e8 commit f6cf3d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vite/src/node/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type PackageCache = Map<string, PackageData>

export interface PackageData {
dir: string
hasSideEffects: (id: string) => boolean | 'no-treeshake'
hasSideEffects: (id: string) => boolean | 'no-treeshake' | null
webResolvedImports: Record<string, string | undefined>
nodeResolvedImports: Record<string, string | undefined>
setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void
Expand Down Expand Up @@ -171,7 +171,7 @@ export function loadPackageData(pkgPath: string): PackageData {
const data = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
const pkgDir = path.dirname(pkgPath)
const { sideEffects } = data
let hasSideEffects: (id: string) => boolean
let hasSideEffects: (id: string) => boolean | null
if (typeof sideEffects === 'boolean') {
hasSideEffects = () => sideEffects
} else if (Array.isArray(sideEffects)) {
Expand All @@ -191,7 +191,7 @@ export function loadPackageData(pkgPath: string): PackageData {
resolve: pkgDir,
})
} else {
hasSideEffects = () => true
hasSideEffects = () => null
}

const pkg: PackageData = {
Expand Down

0 comments on commit f6cf3d1

Please sign in to comment.