-
-
Notifications
You must be signed in to change notification settings - Fork 230
refactor(core): using import defer #6490
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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 dynamic imports to use deferred imports, converting async module loading to synchronous top-level imports with the defer modifier. This optimization eliminates unnecessary async operations while enabling Rspack's experimental deferImport feature for better build performance.
Key changes:
- Convert dynamic
import()calls todefer * asimports across multiple server-side modules - Change async functions to synchronous where dynamic imports were the only async operations
- Enable Rspack's experimental
deferImportfeature in the build configuration - Update TypeScript module configuration from
ES2022toesnext - Add
@prettier/plugin-oxcfor enhanced code formatting
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/config/tsconfig.json | Updated module target to esnext to support newer module features |
| packages/core/src/server/runner/asModule.ts | Replaced dynamic import with deferred import for node:vm |
| packages/core/src/server/prodServer.ts | Replaced dynamic imports with deferred imports for node:zlib and converted createHttpServer call to synchronous |
| packages/core/src/server/open.ts | Replaced dynamic imports with deferred imports for node:child_process and node:util, made getHostInUrl synchronous |
| packages/core/src/server/httpServer.ts | Replaced dynamic imports with deferred imports for http modules and converted function to synchronous |
| packages/core/src/server/hmrFallback.ts | Replaced dynamic import with deferred import for node:dns |
| packages/core/src/server/helper.ts | Replaced dynamic imports with deferred imports for node:net and made getHostInUrl synchronous |
| packages/core/src/server/devServer.ts | Removed await from createHttpServer call |
| packages/core/src/server/cliShortcuts.ts | Replaced dynamic import with deferred import for node:readline |
| packages/core/src/plugins/cache.ts | Removed await from hash function call |
| packages/core/src/loadConfig.ts | Replaced dynamic import with deferred import for jiti |
| packages/core/src/helpers/index.ts | Converted hash function from async to sync with deferred crypto import |
| packages/core/src/createContext.ts | Removed await from hash function call |
| packages/core/rslib.config.ts | Enabled Rspack's experimental deferImport feature |
| package.json | Added @prettier/plugin-oxc dev dependency |
| .prettierrc | Configured Prettier to use oxc plugin |
| pnpm-lock.yaml | Updated lock file with new dependencies |
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
WIP
TODO
typescript-goto support import defer. (Port "Add support forimport deferproposal" microsoft/typescript-go#1826)import deferyet (can be resolved via@prettier/plugin-oxc) (typescript import defer error prettier/prettier#18180)Checklist