Skip to content

Commit

Permalink
fix(rollup): also match moduleSideEffects with full path
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 12, 2022
1 parent 81efead commit ce2e898
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/rollup/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pathToFileURL } from 'url'
import { dirname, join, relative, resolve } from 'pathe'
import { dirname, join, normalize, relative, resolve } from 'pathe'
import type { InputOptions, OutputOptions } from 'rollup'
import defu from 'defu'
import devalue from '@nuxt/devalue'
Expand Down Expand Up @@ -109,7 +109,9 @@ export const getRollupConfig = (nitro: Nitro) => {
},
treeshake: {
moduleSideEffects (id) {
return nitro.options.moduleSideEffects.some(match => id.startsWith(match))
const normalizedId = normalize(id)
const idWithoutNodeModules = normalizedId.split('node_modules/').pop()
return nitro.options.moduleSideEffects.some(m => normalizedId.startsWith(m) || idWithoutNodeModules.startsWith(m))
}
}
}
Expand Down

0 comments on commit ce2e898

Please sign in to comment.