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

feat: support for self-referencing #16068

Merged
merged 5 commits into from
Mar 12, 2024

Conversation

XiSenao
Copy link
Collaborator

@XiSenao XiSenao commented Mar 1, 2024

Description

fix: #9731

Additional context

Support for self-referencing seems to be in line with expectations in terms of functionality, but I'm not sure if there's anything else that needs to be considered.


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, especially the Pull Request Guidelines.
  • 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).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link

stackblitz bot commented Mar 1, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@XiSenao XiSenao changed the title support for self-referencing feat: support for self-referencing Mar 1, 2024
@XiSenao XiSenao added the p3-minor-bug An edge case that only affects very specific usage (priority) label Mar 1, 2024
@sapphi-red sapphi-red requested a review from bluwy March 1, 2024 12:46
@XiSenao XiSenao requested a review from sapphi-red March 7, 2024 12:16
@patak-dev
Copy link
Member

/ecosystem-ci run

bluwy
bluwy previously approved these changes Mar 8, 2024
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Awesome work! Did a few tests locally and it seems to handle all the edge cases. I'm not sure why Nuxt is failing, but I triggered a rerun for it.

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 7018ee5: Open

suite result latest scheduled
analogjs failure failure

astro, histoire, ladle, laravel, marko, nuxt, previewjs, qwik, rakkas, sveltekit, unocss, vike, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-pages, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest

patak-dev
patak-dev previously approved these changes Mar 8, 2024
@patak-dev patak-dev added this to the 5.2 milestone Mar 8, 2024
Comment on lines 758 to 765
// check if it's a self reference dep.
const selfPackageData = findNearestPackageData(basedir, packageCache)
pkg =
selfPackageData?.data.exports && selfPackageData?.data.name === pkgId
? selfPackageData
: null
}
return
if (!pkg) return
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 this code should be before const pkg = resolvePackageData(pkgId, basedir, preserveSymlinks, packageCache).

PACKAGE_SELF_RESOLVE (9.) is called before the resolution loop (11.).
https://nodejs.org/api/esm.html#resolution-algorithm:~:text=Let%20selfUrl%20be%20the%20result%20of%20PACKAGE_SELF_RESOLVE(packageName%2C%20packageSubpath%2C%20parentURL).
It only affects a case when you have a dep with the same name though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, already updated

@XiSenao XiSenao dismissed stale reviews from patak-dev and bluwy via 49588a6 March 9, 2024 12:06
@XiSenao
Copy link
Collaborator Author

XiSenao commented Mar 9, 2024

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 49588a6: Open

suite result latest scheduled
analogjs success failure

astro, histoire, ladle, laravel, marko, nuxt, previewjs, qwik, rakkas, sveltekit, unocss, vike, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-pages, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vitest

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

Thanks!

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
4 participants