Skip to content

Conversation

@magic-akari
Copy link
Contributor

Summary

Related links

Checklist

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

Copilot AI review requested due to automatic review settings November 27, 2025 10:32
@netlify
Copy link

netlify bot commented Nov 27, 2025

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 6340d36
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/69305670e35d8a0008429dc1

@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Nov 27, 2025
Copilot finished reviewing on behalf of magic-akari November 27, 2025 10:35
Copy link
Contributor

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 adds comprehensive support for Node.js ESM features import.meta.filename, import.meta.dirname, and import.meta.resolve to align with modern Node.js module capabilities. The implementation handles various configuration modes (mock, warn-mock, eval-only, node-module, true, false) and supports both CommonJS and ESM output formats, with intelligent behavior based on target environment capabilities.

Key Changes:

  • Extended NodeStuffPlugin to handle import.meta.dirname/filename alongside existing __dirname/__filename support
  • Implemented import.meta.resolve() functionality with new dependency types for module resolution
  • Added importMetaDirnameAndFilename environment configuration option to control native support detection
  • Changed DestructuringAssignmentProperties from FxHashSet to FxIndexSet to preserve property order

Reviewed changes

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

Show a summary per file
File Description
crates/rspack_plugin_javascript/src/parser_plugin/node_stuff_plugin.rs Core implementation for handling import.meta.dirname/filename with various node option modes, including member access, destructuring, and typeof operations
crates/rspack_plugin_javascript/src/parser_plugin/import_meta_plugin.rs Added import.meta.resolve support with call handling and evaluation, plus special handling to skip dirname/filename evaluation (delegated to NodeStuffPlugin)
crates/rspack_plugin_javascript/src/visitors/dependency/parser/mod.rs Updated parser plugin registration to support ESM-only NodeStuffPlugin instances; changed DestructuringAssignmentProperties to use FxIndexSet for order preservation
crates/rspack_plugin_javascript/src/dependency/esm/import_meta_resolve_dependency.rs New dependency type for handling import.meta.resolve() module references
crates/rspack_plugin_javascript/src/dependency/esm/import_meta_resolve_header_dependency.rs Header dependency for import.meta.resolve to replace callee with comment marker
crates/rspack_core/src/options/output.rs Added import_meta_dirname_and_filename option to Environment config
crates/rspack_core/src/dependency/dependency_type.rs Added ImportMetaResolve dependency type enum variant
crates/rspack_binding_api/src/raw_options/raw_output.rs Exposed import_meta_dirname_and_filename option in binding API
crates/node_binding/napi-binding.d.ts TypeScript definition for new importMetaDirnameAndFilename option
crates/rspack_plugin_rslib/src/plugin.rs Updated to use new NodeStuffPlugin constructor with esm_only parameter
tests/rspack-test/configCases/node/filename-and-dirname/* Comprehensive test suite covering all node option modes for both CJS and ESM formats
crates/rspack/tests/snapshots/defaults__default_options.snap Updated snapshot reflecting new environment option

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@magic-akari magic-akari marked this pull request as draft November 27, 2025 10:40
@magic-akari magic-akari force-pushed the fix/issue-8008 branch 2 times, most recently from 17c8bf5 to 47562ad Compare November 27, 2025 12:37
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 27, 2025

CodSpeed Performance Report

Merging #12317 will not alter performance

Comparing magic-akari:fix/issue-8008 (6340d36) with main (39f82ff)

Summary

✅ 17 untouched

@magic-akari magic-akari marked this pull request as ready for review November 27, 2025 13:07
@magic-akari magic-akari requested a review from Copilot November 27, 2025 13:08
Copilot finished reviewing on behalf of magic-akari November 27, 2025 13:09
Copy link
Contributor

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

Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@magic-akari magic-akari force-pushed the fix/issue-8008 branch 2 times, most recently from aeeede2 to 8a4dce6 Compare December 3, 2025 13:57
Copy link
Contributor

@LingyuCoder LingyuCoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@LingyuCoder LingyuCoder merged commit c7f428b into web-infra-dev:main Dec 4, 2025
52 checks passed
@magic-akari magic-akari deleted the fix/issue-8008 branch December 4, 2025 02:52
@chenjiahan
Copy link
Member

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support import.meta.resolve + Node Specific Meta Values

3 participants