Speed up vite-plugin-solid with vite hook filters

Open
#259 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

The issue does not name a file or test; locate the Vite plugin transform hooks in the solid-vite-plugin source and compare their current id checks with the hook-filter API linked in the report. Preserve backward compatibility as described, then verify the plugin's Vite build behavior and the reported transform performance improvement.

Written by the indexing model from the issue text.

Description

During our vite build a significant amount of time (60+%) is spent in vite plugin solid.

Image

Since rolldown vite plugins can be sped up significantly with hook filters to allow for fewer Rust to JS calls.
https://rolldown.rs/apis/plugin-api/hook-filters

By turning this:

export default function myPlugin() {
  return {
    name: 'example',
    transform(code, id) {
      if (!id.endsWith('.data')) {
        // early return
        return
      }
      // perform actual transform
      return transformedCode
    },
  }
}

into this

export default function myPlugin() {
  return {
    name: 'example',
    transform: {
      filter: {
        id: /\.data$/
      },
      handler(code) {
        // perform actual transform
        return transformedCode
      },
    }
  }
}

Backward compatibility

The syntax has supported since vite 6.3+ and could be made backward compatible by leaving the checks in the handlers.

Implementation

Would you be interested in a PR for this change?

Dominant language
TypeScript
Stars
520
Forks
70
Avg merge
23h 35m
Merged PRs (30d)
39

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.

More from solidjs/solid-vite-plugin

All issues in solidjs/solid-vite-plugin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.