feat!: add test option to preact refresh plugin#71
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb6c20f8d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR adds a new test option to @rspack/plugin-preact-refresh to control loader matching independently of include, aligning behavior and defaults with @rspack/plugin-react-refresh by moving the extension-based matcher to test and leaving include unset unless configured.
Changes:
- Add
testoption to plugin API and use it as the Rspack rule’stestcondition. - Update defaults so
testmatches common JS/TS extensions (includingmjs/cjsvariants) whileincludedefaults toundefined. - Add config-case tests and update README documentation for the new option and revised
includesemantics.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/configCases/condition/test/rspack.config.js | Adds a config-case verifying test can target specific modules independently of include. |
| test/configCases/condition/test/index.js | Asserts the selected module is processed (refresh utils injected) when test matches. |
| test/configCases/condition/test/file.js | Imports a target module (foo) to exercise test matching. |
| test/configCases/condition/default-test/rspack.config.js | Adds a config-case validating default test behavior without options. |
| test/configCases/condition/default-test/index.js | Asserts default test processes .mjs files. |
| test/configCases/condition/default-test/file.mjs | Provides an .mjs module to validate default matching. |
| src/index.ts | Introduces test option, changes normalization/defaults, and wires test/include into the injected module rule. |
| README.md | Documents the new test option and updates include docs/defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR adds a
testoption to@rspack/plugin-preact-refreshso loader matching can be configured separately frominclude, matching@rspack/plugin-react-refresh. It also aligns the defaults by moving the extension matcher totestand leavingincludeundefined unless explicitly configured.Validation
pnpm buildpnpm lintpnpm test