Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

fix(vite): ignore virtual imports that aren't in vfs - #4822

Merged
pi0 merged 6 commits into
nuxt:mainfrom
derz:main
May 6, 2022
Merged

fix(vite): ignore virtual imports that aren't in vfs#4822
pi0 merged 6 commits into
nuxt:mainfrom
derz:main

Conversation

@derz

@derzderz commented May 5, 2022

Copy link
Copy Markdown
Contributor

Avoids rollup error plugin load hook should return a string, a { code, map } object, or nothing/null when using (custom) virtual imports.

🔗 Linked issue

nuxt/nuxt#13921

❓ 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

Check if the virtual module exist in nuxt and otherwise just ignore it (aka leave it up for the other loaders to handle that module). Avoids returning { code: null, map: null }.

Resolvesnuxt/nuxt#13921

📝 Checklist

  • I have linked an issue or discussion.
  • [] n/a. I have updated the documentation accordingly.

…nothing
Avoids rollup error `plugin load hook should return a string, a { code, map } object, or nothing/null` when using (custom) virtual imports.
@netlify

netlifyBot commented May 5, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit94dde9c
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/627505d65720020008c5f5b7

@danielroedanielroe added bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage vite labels May 5, 2022

@danielroedanielroe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like a good fix to me. Alternatively, we could change the prefix we're using here to virtual:nuxt or something.

@danielroedanielroe changed the title fix: check if virtual: import is handled via nuxt & otherwise ignore itfix(vite): ignore virtual: imports that aren't in vfsMay 5, 2022
@pi0

pi0 commented May 6, 2022

Copy link
Copy Markdown
Member

@danielroe Can you please check failing CI?

Comment threadpackages/vite/src/plugins/virtual.ts Outdated
Comment threadpackages/vite/src/plugins/virtual.ts Outdated
@danielroedanielroe changed the title fix(vite): ignore virtual: imports that aren't in vfsfix(vite): ignore virtual imports that aren't in vfsMay 6, 2022
pi0
pi0 approved these changes May 6, 2022
@pi0
pi0 merged commit 31c67ad into nuxt:mainMay 6, 2022
@pi0

pi0 commented May 6, 2022

Copy link
Copy Markdown
Member

Thanks @derz 💯

@pi0pi0 mentioned this pull request May 6, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't working🔨 p3-minor-bugPriority 3: a bug in an edge case that only affects very specific usagevite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using custom virtual imports result in rollup error on build

3 participants

@derz@pi0@danielroe