Skip to content

Conversation

Timeless0911
Copy link
Contributor

Summary

__filename and __dirname shims should work in 'javascript/esm' files.

Related Links

web-infra-dev/rspack#11840

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Copilot Copilot AI review requested due to automatic review settings October 16, 2025 09:21
Copy link
Contributor

@Copilot Copilot AI left a 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 fixes Node.js shims (__filename and __dirname) to work properly in 'javascript/esm' files by adding support for .mjs files and ensuring the RslibPlugin forces Node shims when these variables are enabled in ESM shim configuration.

  • Added test coverage for Node.js shims in .mjs files
  • Updated RslibPlugin configuration to force Node shims when ESM shims are enabled
  • Enhanced test configuration to include a new ESM bundle with .mjs entry point

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/integration/shims/index.test.ts Added test case for Node.js shims in .mjs files and updated existing test references
tests/integration/shims/esm/src/node.mjs New test file demonstrating __dirname and __filename usage in ESM module
tests/integration/shims/esm/rslibShimsDisabled.config.ts Updated to include all lib configurations in shims disabled tests
tests/integration/shims/esm/rslib.config.ts Added new ESM bundle configuration for .mjs file testing and reformatted existing configs
packages/core/src/config.ts Added forceNodeShims option to RslibPlugin based on enabled ESM shims

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@JSerFeng JSerFeng merged commit b0e5e09 into main Oct 16, 2025
14 checks passed
@JSerFeng JSerFeng deleted the fix/mjs-node-shims branch October 16, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants