Skip to content

Supporting virtual:* modules? #986

@quick-vite

Description

@quick-vite

Hi,

Vite offers a plugin construct where you can define "virtual modules". ( import packageName from 'virtual:{package-name}')
In short, when bundling you can refer to this "module" and inject code into the bundle.
This can be very useful for including build-time generated framework metadata for example.

Currently, when you try to compile a JSR package using this construct you get an error:

error: Unsupported scheme "virtual" for module "virtual:{package-name}". Supported schemes:
 - "blob"
 - "data"
 - "file"
 - "http"
 - "https"
 - "jsr"
 - "npm"
    at file:///home/runner/work/file.mts:3:27
Child process exited with: 1
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

I'm not sure if it's in JSR's interest to support this, because it seems to check whether your dependencies actually resolve.
(I tried replacing it with npm:virtual:{package-name} and got an error because of that.
But I figured I'd make an issue anyway so it's documented if JSR doesn't want to support it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions