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: defaultRequestToFile should handle uncached node_modules request #230

Merged
merged 2 commits into from
May 22, 2020

Conversation

csr632
Copy link
Member

@csr632 csr632 commented May 22, 2020

Fix: #228

Let me explain with this reproduce repo: https://github.com/csr632/test-vite/tree/wrong-resolve
When dev server is re-writing this module: test-package/es/index.js
vite go to this line:
https://github.com/csr632/vite/blob/ada8886e36578c7f43b7cd12bacd65e5a7c4c6e4/src/node/server/serverPluginModuleRewrite.ts#L243
with pathname being "/@modules/test-package/es/nested", which is not cached by idToFileMap:https://github.com/csr632/vite/blob/e786897134cb35ca19f4358c2829a82a1b3269e7/src/node/resolver.ts#L28
Previously defaultRequestToFile do nothing when this happen, and return path.join(root, publicPath.slice(1)), which doesn't make sense because publicPath is something like /@modules/test-package/es/nested.

}
const resolved = resolveNodeModuleFile(root, id)
if (!resolved) throw new Error(`Can't resolve "${id}"`)
Copy link
Member Author

@csr632 csr632 May 22, 2020

Choose a reason for hiding this comment

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

It doesn't make sense to continue, so I throw here. Is there a better choice?

Copy link
Member

Choose a reason for hiding this comment

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

It will eventually error elsewhere, it's better to let it pass through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants