Skip to content

Commit

Permalink
fix: only handle merge ssr.noExternal (#8003)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored May 3, 2022
1 parent f1af941 commit 642d65b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 24 additions & 0 deletions packages/vite/src/node/__tests__/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,30 @@ describe('mergeConfig', () => {

expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig)
})

test('handles ssr.noExternal', () => {
const baseConfig = {
ssr: {
noExternal: true
}
}

const newConfig = {
ssr: {
noExternal: ['foo']
}
}

const mergedConfig = {
ssr: {
noExternal: true
}
}

// merging either ways, `ssr.noExternal: true` should take highest priority
expect(mergeConfig(baseConfig, newConfig)).toEqual(mergedConfig)
expect(mergeConfig(newConfig, baseConfig)).toEqual(mergedConfig)
})
})

describe('resolveConfig', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,11 @@ function mergeConfigRecursively(
} else if (key === 'assetsInclude' && rootPath === '') {
merged[key] = [].concat(existing, value)
continue
} else if (key === 'noExternal' && (existing === true || value === true)) {
} else if (
key === 'noExternal' &&
rootPath === 'ssr' &&
(existing === true || value === true)
) {
merged[key] = true
continue
}
Expand Down

0 comments on commit 642d65b

Please sign in to comment.