refactor(core): use named import from node:module for require shim#1431
refactor(core): use named import from node:module for require shim#1431Timeless0911 merged 1 commit intomainfrom
Conversation
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
LGTM, IIRC, Deno also requires |
There was a problem hiding this comment.
Pull request overview
This PR refactors the requireShim implementation to use a named import from node:module instead of a default import, aligning with modern Node.js practices and improving consistency across the codebase.
Key changes:
- Updated the require shim to use
import { createRequire } from "node:module"instead ofimport __rslib_shim_module__ from 'module' - Simplified the implementation by directly calling
createRequire(import.meta.url)instead of__rslib_shim_module__.createRequire(import.meta.url)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/core/src/plugins/shims.ts |
Updated requireShim constant to use named import pattern |
tests/integration/shims/index.test.ts |
Updated test snapshot to match the new import pattern |
website/docs/en/config/lib/shims.mdx |
Updated documentation example to reflect the new implementation |
website/docs/zh/config/lib/shims.mdx |
Updated Chinese documentation example to reflect the new implementation |
The changes are clean, well-coordinated across code, tests, and documentation, and consistent with the existing patterns used elsewhere in the codebase. No issues were identified during this review.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR updates the implementation of
requireShimto use a named import fromnode:moduleinstead of the default import. This aligns with modern Node.js practices and ensures better compatibility.Specifically, it changes:
I have also updated the relevant integration tests (
tests/integration/shims/index.test.ts) and documentation (website/docs/en/config/lib/shims.mdx,website/docs/zh/config/lib/shims.mdx) to reflect this change.Related Links
Checklist