-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Virtual modules in lib mode no longer work #5641
Comments
As you might have seen the related issues on that PR:
I think that the previous behavior was more broken for how it's special-casing the package with a path like As suggested in the other issues, can you try |
I think this is also an error with Vitest.
If it failed, then it cannot be imported, because Node.js will try to read the file anyway. Also accepting any file schemas that are not supported by node.js looks like a bug on our side. |
Should it make a difference that the virtual modules are already aliased https://github.com/rhino-project/rhino-project/blob/beta/packages/core/vite.config.ts#L48? (#5601 (comment)) Based on the docs https://vitest.dev/guide/mocking.html#virtual-modules |
@jprosevear Your repro is a little too big to quickly see through, but I'm expecting that |
vitest/packages/vite-node/src/externalize.ts Lines 14 to 16 in becabb5
(though I agree that catching What I suspected is that OP has an ESM package, which uses // op-package/package.json
{
"type": "module",
"exports": "./dist/esm/index.js"
}
// op-package/dist/esm/index.js
import "virtual:something"; In this case, previously Vitest inlined What I couldn't get from a glance is that OP's project seems to be monorepo, so I didn't think workspace package would end up |
This is essentially what is going on.
It is another workspace package that is doing the virtual import. server.deps.inline worked - thanks! https://vitest.dev/guide/mocking.html#virtual-modules might need some tweaking? |
Describe the bug
Upgrading to 1.5.0 or newer causes library mode with virtual modules to break with error:
Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'virtual:'
#5416 seems to have causes this, because the following patch applied with pnpm causes the error to pass and all tests to pass:
1.2.2 does not have this issue nor does 1.4.0.
Reproduction
See - rhino-project/rhino-project/pull/106
this should pass
Will fail
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: