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: Vite cannot load configuration files in the link directory (#4180) #4181

Merged
merged 5 commits into from
May 13, 2022
Merged

fix: Vite cannot load configuration files in the link directory (#4180) #4181

merged 5 commits into from
May 13, 2022

Conversation

yinzhenyu-su
Copy link
Contributor

@yinzhenyu-su yinzhenyu-su commented Jul 9, 2021

Description

fix #4180

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Shinigami92 Shinigami92 added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jul 9, 2021
@Fl0pZz
Copy link

Fl0pZz commented Aug 20, 2021

@Shinigami92 what about check this PR? <3

@@ -889,7 +889,7 @@ async function loadConfigFromBundledFile(
const extension = path.extname(fileName)
const defaultLoader = require.extensions[extension]!
require.extensions[extension] = (module: NodeModule, filename: string) => {
if (filename === fileName) {
if (filename === fs.realpathSync(fileName)) {
Copy link
Member

Choose a reason for hiding this comment

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

@patak-js Wasn't there something about realpathSync that it is bad? Cause it is slow or something?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know, we are not using it in the codebase. But we are using its async version realPath here:

sourceRoot = await fs.realpath(
, so I don't think performance is an issue here. It is only while reading the config file. But I let others more used to linked files to check this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think fs.realpathSync(fileName) will be called many times, if it is here and require exists inside the config.
How about caching it like this?

const realFileName = fs.realpathSync(fileName)
require.extensions[extension] = (module: NodeModule, filename: string) => {
  if (filename === realFileName) {

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense @sapphi-red, would you like to send a commit with that change to this PR directly?

Copy link
Member

Choose a reason for hiding this comment

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

I updated 👍

@patak-dev patak-dev merged commit a3fa1a3 into vitejs:main May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vite cannot load configuration files in the link directory
5 participants