Skip to content

Add support for Rolldown/Vite hook filters #749

@s1gr1d

Description

@s1gr1d

This came up on X where someone compared the load times: https://x.com/TheAlexLichter/status/1930977073931206928

The problem hook filters solve is getting rid of the JS-to-Rust overhead by only invoking a plugin call when it's necessary. For example in this case, we can add a hook filter, that only considers files which include .data:

    transform(code, id) {
      if (!id.endsWith('.data')) { }
    }

With a filter, this looks like this:

    transform: {
      filter: {
        id: /\.data$/
      },
      handler (code) { /* the actual transform handler code */ } 

The feature is also supported by Rollup 4.38.0+ and Vite 6.3.0+.

Docs: Rolldown
Docs: Vite

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions