Skip to content

Speed up vite-plugin-solid with vite hook filters #259

@ChristophP

Description

@ChristophP

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

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions