-
-
Notifications
You must be signed in to change notification settings - Fork 56
fix: use native plugin to handle hashbang and react directives #1331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b0ff1b8 to
65a2f10
Compare
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
3b2dc19 to
1b8e9a0
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors hashbang (#!) and React directive handling by delegating them to Rspack's native plugin instead of handling them in the Rslib loader/plugin. The change simplifies the codebase and leverages native functionality.
Key Changes
- Removed hashbang and React directive handling logic from
EntryChunkPluginandentryModuleLoader - Added
directives: falseto minify configuration to preserve directive prologues - Made entry module loader conditional based on
advancedEsmflag - when enabled, no loader is needed
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/plugins/entryModuleLoader.ts | Simplified to empty pass-through loader for creating entry module doppelganger |
| packages/core/src/plugins/EntryChunkPlugin.ts | Removed shebang/directive handling logic and related state tracking; added useLoader parameter |
| packages/core/src/constant.ts | Removed unused shebang and React directive constants |
| packages/core/src/config.ts | Added directives: false to minify config and conditional loader usage based on advancedEsm |
| tests/integration/directive/react/bundleless/rslib.config.ts | Added minify configuration with comment explaining directives: false option |
| tests/integration/directive/index.test.ts | Updated test expectations to match native plugin output format (double quotes, preserved directives) |
| tests/integration/entry/index.test.ts | Updated snapshots for new chunk organization with advancedEsm |
| tests/integration/shims/index.test.ts | Made regex pattern more flexible to handle dynamic chunk IDs |
| packages/core/tests/config.test.ts | Updated test snapshot to include directives: false |
| packages/core/tests/snapshots/config.test.ts.snap | Updated all snapshots to reflect removed directive handling and added minify option |
| pnpm-lock.yaml | Bumped @rspack/plugin-react-refresh from 1.5.2 to 1.5.3 |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
fix #316.
in this PR:
depends on depends on web-infra-dev/rspack#12168, the native Rslib plugin has handled hashbang and react directives.
with
advancedEsmno entry dedicated loader anymore,
advancedEsmcan handle "the issue of a module acting as both an entry module and a non-entry module is that the module graph can affect each other".without
advancedEsmstill using a dedicated loader, but only an empty loader to make the doppelganger. the loader will not handle hashbang and react directives anymore (already handled in native plugin).
Related Links
Checklist