Skip to content

[Feature]: support conditionally running loaders based on module contents #14983

Description

@mjames-c

What problem does this feature solve?

My company, Canva, currently has an expensive Babel loader with many custom Babel plugins. These plugins only need to run against a subset of source code and so we have a quick check on the JS side which acts as a pass through for files which do NOT need to be babel transformed.

Being able to move this check to the Rust side would speed things up as we avoid message passing back and worth between the Rust and JS side.

What does the proposed API of configuration look like?

open to suggestions but something like rules[].contentInclude

type ContentInclude = Array<{
  id: string;
  condition: Condition;
}>

If one or more conditions match the loader is invoked. If a loader is invoked the ids of the matching conditions are passed to it so it can make decisions based on them.

https://rspack.rs/config/module-rules#condition

Metadata

Metadata

Assignees

Labels

pending triageThe issue/PR is currently untouched.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions