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

Support monorepo package self-references #8820

Merged
merged 6 commits into from
Jul 29, 2024

Conversation

mischnic
Copy link
Contributor

@mischnic mischnic commented Jul 23, 2024

Closes PACK-3107

Packages importing themselves works fine for packages from npm, since they always live at .../node_modules/foo anyway and so the regular node_modules resolution covers self-references as well.

This is not the case for (symlinked) monorepo workspaces, which this PR fixes. This essentially adds the LOAD_PACKAGE_SELF step from https://nodejs.org/api/modules.html#all-together .

I think the logic is sound, should I extract this into a separate function? Or is there a better place to put this anyway?

Copy link

vercel bot commented Jul 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:39am

@mischnic mischnic changed the title Improve rustdoc Support monorepo package self-references Jul 23, 2024
Copy link
Contributor

github-actions bot commented Jul 23, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

✅ This change can build next-swc

Copy link
Contributor

github-actions bot commented Jul 23, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

fragment,
options,
);
if !(*result.is_unresolveable().await?) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we continue to look for other packages with the same name or should this better fail resolving here if the self reference doesn't resolve?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's an uncommon case, but https://nodejs.org/api/modules.html#all-together would continue searching. So I'm inclined to continue as well

@mischnic mischnic merged commit f998231 into main Jul 29, 2024
58 of 60 checks passed
@mischnic mischnic deleted the mischnic/pack-3107-self-reference-unpublished branch July 29, 2024 09:05
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
Closes PACK-3107

Packages importing themselves works fine for packages from npm, since
they always live at `.../node_modules/foo` anyway and so the regular
node_modules resolution covers self-references as well.

This is not the case for (symlinked) monorepo workspaces, which this PR
fixes. This essentially adds the `LOAD_PACKAGE_SELF` step from
https://nodejs.org/api/modules.html#all-together .
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
Closes PACK-3107

Packages importing themselves works fine for packages from npm, since
they always live at `.../node_modules/foo` anyway and so the regular
node_modules resolution covers self-references as well.

This is not the case for (symlinked) monorepo workspaces, which this PR
fixes. This essentially adds the `LOAD_PACKAGE_SELF` step from
https://nodejs.org/api/modules.html#all-together .
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
Closes PACK-3107

Packages importing themselves works fine for packages from npm, since
they always live at `.../node_modules/foo` anyway and so the regular
node_modules resolution covers self-references as well.

This is not the case for (symlinked) monorepo workspaces, which this PR
fixes. This essentially adds the `LOAD_PACKAGE_SELF` step from
https://nodejs.org/api/modules.html#all-together .
mischnic added a commit to vercel/next.js that referenced this pull request Aug 7, 2024
I've simplified @timneutkens's tests from #66486
The resolver fix is in vercel/turborepo#8820

Closes #66486
Related issue: #66487

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants