Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ssr.external/noExternal should apply to packageName #9146

Merged
merged 1 commit into from Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/vite/src/node/ssr/ssrExternal.ts
Expand Up @@ -120,13 +120,17 @@ export function createIsConfiguredAsSsrExternal(
return (id: string) => {
const { ssr } = config
if (ssr) {
if (ssr.external?.includes(id)) {
const pkgName = getNpmPackageName(id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getNpmPackageName returns '' for id='/some/path/with/leading/slash' which is falsy and returns undefined then. This is what we want, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only bare imports reach this check, so this is not possible 👍🏼

if (!pkgName) {
return undefined
}
if (ssr.external?.includes(pkgName)) {
return true
}
if (typeof noExternal === 'boolean') {
return !noExternal
}
if (noExternalFilter && !noExternalFilter(id)) {
if (noExternalFilter && !noExternalFilter(pkgName)) {
return false
}
}
Expand Down