Skip to content

Commit

Permalink
perf: add back scan check, as we don't need side effects in the scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Apr 7, 2023
1 parent 34b9886 commit 5ac3a4d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -274,6 +274,7 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
// hints so the non-used code is properly tree-shaken during build time.
if (
!options.idOnly &&
!options.scan &&
options.isBuild &&
!importer?.endsWith('.html')
) {
Expand Down Expand Up @@ -788,7 +789,10 @@ export function tryNodeResolve(
return { ...resolved, id: resolvedId, external: true }
}

if (!options.idOnly && ((isBuild && !depsOptimizer) || externalize)) {
if (
!options.idOnly &&
((!options.scan && isBuild && !depsOptimizer) || externalize)
) {
// Resolve package side effects for build so that rollup can better
// perform tree-shaking
return processResult({
Expand Down Expand Up @@ -868,7 +872,7 @@ export function tryNodeResolve(
resolved = depsOptimizer!.getOptimizedDepId(optimizedInfo)
}

if (!options.idOnly && isBuild) {
if (!options.idOnly && !options.scan && isBuild) {
// Resolve package side effects for build so that rollup can better
// perform tree-shaking
return {
Expand Down Expand Up @@ -1229,7 +1233,7 @@ function tryResolveBrowserMapping(
if (options.idOnly) {
return result
}
if (options.isBuild) {
if (!options.scan && options.isBuild) {
const resPkg = findNearestPackageData(
path.dirname(res),
options.packageCache,
Expand Down

0 comments on commit 5ac3a4d

Please sign in to comment.