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(optimizer): resolve relative path by Vite resolver (fixes #8704) #8706

Closed

Conversation

sapphi-red
Copy link
Member

Description

fixes #8702
fixes #8704

I think we faced a bug which was previously undiscovered. We should resolve relative paths with our resolution logic for cases like this. Otherwise, resolve.mainFields and others won't be applied.
#8702 (reply in thread)

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.

@sapphi-red sapphi-red added the p4-important Violate documented behavior or significantly improves performance (priority) label Jun 22, 2022
@netlify
Copy link

netlify bot commented Jun 22, 2022

Deploy Preview for vite-docs-main ready!

Name Link
🔨 Latest commit 79c10e6
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62b2bebc1a4ffc0009eb3879
😎 Deploy Preview https://deploy-preview-8706--vite-docs-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@sapphi-red sapphi-red changed the title fix(optimizer): resolve relative path by Vite resolver (fixes fix(optimizer): resolve relative path by Vite resolver (fixes #8704) Jun 22, 2022
@sapphi-red sapphi-red force-pushed the fix/relative-main-field-resolution branch from d853bf1 to 79c10e6 Compare June 22, 2022 07:03
@patak-dev
Copy link
Member

Looks good to me. @sapphi-red could there be performance implications here? I wonder why this wasn't the implementation from the way go. Maybe we had a lot of issues with our own resolver, so it was better to trust esbuild here.
Let's see how well this work in practice, we could also get back to using esbuild for resolving if we find a lot of issues while working them out. But for the beta, I think we should merge and gather feedback.

@sapphi-red
Copy link
Member Author

I think it could be. But it's more consistent so I think it's worth to try it, too.

@sapphi-red sapphi-red marked this pull request as draft June 22, 2022 07:59
@sapphi-red
Copy link
Member Author

This PR breaks this https://stackblitz.com/edit/vitejs-vite-rguug6?file=package.json&terminal=dev.
I'm not sure why but I was not able to convert this to a testcase.

@sapphi-red
Copy link
Member Author

Closing as #8714 is merged and this PR needs to solve the following things:

@sapphi-red sapphi-red closed this Sep 7, 2022
@smeng9
Copy link
Contributor

smeng9 commented Sep 8, 2022

Hi @sapphi-red

I have performed a rebase of #8706 on top of main branch, the issue went away.
https://stackblitz.com/edit/vitejs-vite-rguug6?file=package.json&terminal=dev no longer breaks.

Same thing for #8709, I tested against the stackblitz project and dequal gives me true without crashing the page.

@sapphi-red
Copy link
Member Author

@smeng9 Did you check perf implications? I think this PR will make optimize slow.
It'd be ok to go with this if there isn't but I suspect that.
So I think this PR should be solved by using esbuild's options and #7599 should be solved by fixing implementation around idToPkgMap.

@smeng9
Copy link
Contributor

smeng9 commented Sep 9, 2022

The time spent running test suits on CI before and after these changes seems similar.

I am not sure if the test suits go though the optimize-deps phase.

@sapphi-red sapphi-red deleted the fix/relative-main-field-resolution branch October 6, 2022 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

require not resolving js by looking at main in package.json
3 participants