fix: the require() ESM problem when node < 20.19#1340
Merged
Conversation
✅ Deploy Preview for rsdoctor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes ESM compatibility issues for Node.js versions below 18.19 by updating import statements and resolving loader paths more robustly.
- Replaced
fs-extra/esmimports with standardfs-extraimports - Updated file operations to use Node.js built-in
fsmethods instead of fs-extra in some cases - Added fallback logic for loader path resolution to handle both ESM and CJS environments
- Moved
@rsbuild/plugin-check-syntaxfrom devDependencies to dependencies to avoid prebundling issues
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/utils/src/build/file/index.ts | Changed fs-extra import from ESM-specific to standard import |
| packages/sdk/src/sdk/sdk/index.ts | Replaced fs-extra method with Node.js built-in fs methods |
| packages/sdk/src/sdk/sdk/core.ts | Changed from sync to async fs-extra method |
| packages/core/src/inner-plugins/plugins/loader.ts | Added fallback logic to resolve proxy loader paths |
| packages/core/src/build-utils/build/utils/loader.ts | Updated fs-extra import from ESM-specific to standard |
| packages/core/rslib.config.ts | Added comment about ESM file handling |
| packages/core/prebundle.config.mjs | Removed @rsbuild/plugin-check-syntax from prebundle dependencies |
| packages/core/package.json | Moved @rsbuild/plugin-check-syntax to production dependencies |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
036d347 to
fce67ee
Compare
LingyuCoder
previously approved these changes
Oct 10, 2025
fi3ework
reviewed
Oct 11, 2025
fi3ework
approved these changes
Oct 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related Links
#1339