Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nitro): resolve tracked externals #2743

Closed
wants to merge 2 commits into from
Closed

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Jan 16, 2022

πŸ”— Linked issue

resolves nuxt/nuxt#12832, resolves nuxt/bridge#46

https://github.com/vercel/nft/blob/main/src/node-file-trace.ts#L33-L40

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR resolves externals prior to adding to tracked files. @vercel/nft expects paths rather than module ids and would otherwise look for them in the root directory:

https://github.com/vercel/nft/blob/main/src/node-file-trace.ts#L33-L40

I've disabled optimizeDeps in the fixture as vitest seems to be resolving to an optimised version when testing locally: is this intended behaviour @antfu?

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working nitro labels Jan 16, 2022
@danielroe danielroe requested a review from pi0 January 16, 2022 00:05
@danielroe danielroe self-assigned this Jan 16, 2022
@netlify
Copy link

netlify bot commented Jan 16, 2022

βœ”οΈ Deploy Preview for nuxt3-docs canceled.

πŸ”¨ Explore the source changes: 880c465

πŸ” Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/61e4a300a819b20007d1a6c7

@antfu
Copy link
Member

antfu commented Jan 16, 2022

vitest seems to be resolving to an optimised version when testing locally

It shouldn't be. Added the fix in vitest directly vitest-dev/vitest@e379f64 and released in v0.1.17

@@ -58,7 +60,7 @@ export function externals (opts: NodeExternalsOptions): Plugin {
if (!resolved) {
console.warn(`Could not resolve \`${originalId}\`. Have you installed it?`)
} else {
trackedExternals.add(resolved.id)
trackedExternals.add(_require.resolve(resolved.id))
Copy link
Member

Choose a reason for hiding this comment

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

require.resolve conditions are CommonmJS. This is not the best externalization policy IMO when we are using esm Imports (also nft can wrongly copy cjs build and import statement need to pick esm entry). See #1671 for the alternative attempt.

@danielroe danielroe marked this pull request as draft January 17, 2022 12:55
@pi0 pi0 added the pending label Jan 17, 2022
@negezor
Copy link

negezor commented Feb 5, 2022

Is there any news about this PR? This is the only barrier to upgrading to Nuxt Bridge.

@danielroe danielroe closed this Feb 8, 2022
@danielroe
Copy link
Member Author

Closing as this was the wrong approach. The issue to follow is nuxt/nuxt#12833.

@danielroe danielroe deleted the fix/nitro-resolve-traced branch February 8, 2022 12:30
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x bug Something isn't working nitro pending
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't find a module in the monorepo build resolve path support for vercel/nft
4 participants