Conversation
Deploying rstest with
|
| Latest commit: |
001b4a0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://55e64a66.rstest.pages.dev |
| Branch Preview URL: | https://modulenamemapper.rstest.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 001b4a01b9
ℹ️ 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".
| for (const [pattern, replacement] of Object.entries(moduleNameMapper)) { | ||
| const resourceRegExp = new RegExp(pattern); |
There was a problem hiding this comment.
Stop remapping a request after first matching pattern
Jest-style moduleNameMapper semantics depend on first-match-wins order, but this loop creates a separate NormalModuleReplacementPlugin for every pattern, so later patterns still run on a request that was already rewritten by an earlier one. In overlapping configurations (for example, a specific rule plus a broader fallback), the later plugin can override the intended mapping and resolve to the wrong module.
Useful? React with 👍 / 👎.
fi3ework
left a comment
There was a problem hiding this comment.
how could user choose between resolve.alias and resolve.moduleNameMapper.
Compared to |
|
i feel like these two options are too similar for users, especially since they are almost identical when not using regular expressions. what if we provide a built-in plugin called moduleNameMapper? this way, we can avoid extending |
Good idea. We can extract it into a standalone plugin, such as |
maybe rsbuild-plugin-jest-compatible for future Jest fields, or rsbuild-plugin-test-compatible for even Vitest compatible. |
I prefer |
makes sense to me. |
Summary
Implement
resolve.moduleNameMapperconfiguration option for Jest compatibility, allowing users to map module imports using regex patterns. This is similar to Jest's moduleNameMapper configuration.Related Links
close #649
Checklist