vitejs / vitejs/vite

Support loading jsr module specifiers and transpile its commonjs dependencies

Open
#20,003 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
82.9k
Forks
8.8k
Avg merge
1d 23h
Merged PRs (30d)
61

Description

Description

As a developer using Vite and jsr.io I would like to be able to load module specifiers such as npm:@iconify-icon/react@^3.0.0/dist/iconify.mjs in Vite while using node and NPM.

The part that is not working, is picking up the module specifiers and then transpiling commonjs modules.

Suggested solution

Support loading specifiers such as npm:@iconify-icon/react@^3.0.0/dist/iconify.mjs by rewriting them to iconify-icon/react/dist/iconify.mjs and also triggering the commonjs plugin on it to transpile to the contents.

Alternative

I tried creating a plugin for this. For resolveId I was able to get it to work, however the commonjs part seems to be a separate process where it is statically calculated. Is this a correct assumption?

Additional context

Related issue on jsr repo:
https://github.com/jsr-io/jsr/issues/1097

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Vite's resolveId handling for npm: module specifiers and how the CommonJS plugin statically identifies dependencies. Verify the related JSR example and determine how rewritten specifiers reach CommonJS transformation. Done means the stated iconify.mjs specifier loads in Vite and its CommonJS dependencies are transpiled.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.