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(scan): correctly resolve virtual modules #5711

Merged
merged 2 commits into from
Nov 17, 2021

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Nov 16, 2021

Description

Reverts #5659 (cc @benmccann)

Resolve the virtual module to an actual file path for its file imports to be resolved by esbuild. Otherwise the importer would be virtual-module:path/to/file which fails to resolve.

Additional context

Interfering with all Svelte and Vue projects as dependencies aren't properly crawled on first run.


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.

Copy link
Collaborator

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

This change is fine with me as long as we don't reintroduce the html:virtual-module: bug (https://discord.com/channels/804011606160703521/908717851827904532/908719798433771540)

I'm assuming you tested that though? Do all the vite-plugin-svelte tests pass with this change?

@bluwy
Copy link
Member Author

bluwy commented Nov 16, 2021

Yeah' I've tested this locally on vite-plugin-svelte's kit-node test app. I have not run all tests though. (It doesn't seem to like my local environment). But I'm pretty confident that the code we had before wasn't working as expected.

@bluwy
Copy link
Member Author

bluwy commented Nov 16, 2021

To be safe, I can try to get my setup working tomorrow and run the tests again. We may still have time during beta.

@benmccann
Copy link
Collaborator

Hmm. When I run the tests it looks like we go from 3 tests failing before this PR to 73 tests failing after this PR. A lot of the failing tests are in the kit-node test app, so I'm surprised that app worked for you and doesn't seem to be for me

@bluwy
Copy link
Member Author

bluwy commented Nov 17, 2021

There's currently two kinds of tests in vite-plugin-svelte, for dev and build. I think this would fix dev mode tests, and the failed tests you see now could potentially be from the build mode tests? I have another PR (#5714) to address that as kit-node build + preview doesn't work currently due to dedupeRequire.

@bluwy
Copy link
Member Author

bluwy commented Nov 17, 2021

I was (finally) able to get tests running locally. Yeah looks like there's still some things not caught, putting this as draft for now.

@bluwy bluwy marked this pull request as draft November 17, 2021 05:13
@bluwy bluwy marked this pull request as ready for review November 17, 2021 07:14
@bluwy
Copy link
Member Author

bluwy commented Nov 17, 2021

I made the real fix now, and it was because in esbuild, we had to resolve the virtual module to an actual file path for its file imports to be resolved, which was causing the initial html:virtual-module:... bug in the first place. I refactored the code a bit and it's working locally for me now. All tests passing for dev mode.

@patak-dev patak-dev merged commit 01f9b16 into vitejs:main Nov 17, 2021
@bluwy bluwy deleted the fix-virtual-modules-resolve branch November 17, 2021 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants