Skip to content

Conversation

fi3ework
Copy link
Member

Summary

second (final) step after web-infra-dev/rspack#11744.

forbid extra parser to handle module var if ESM syntax is present, common usage and user expectation in package building.

Related Links

Checklist

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

@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 05:59
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 the handling of the module variable in ES modules by preventing extra parser transformations when ESM syntax is present. The fix ensures that when building libraries in ESM format, the module variable is treated as a normal variable rather than being transformed by CommonJS-specific parsers.

  • Updates JavaScript parser configuration to skip CommonJS exports handling in ESM context
  • Adds comprehensive integration tests for module variable handling in both ESM and CJS formats
  • Removes the "type": "module" package.json field from a test to ensure proper testing of mixed environments

Reviewed Changes

Copilot reviewed 12 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/core/src/config.ts Adds commonjs.exports: 'skipInEsm' parser option for ESM format
packages/core/tests/snapshots/config.test.ts.snap Updates test snapshots to reflect new parser configuration
tests/integration/parser-javascript/module/ New test suite with files to verify module variable handling in ESM vs CJS
tests/integration/parser-javascript/api-plugin/ New test for API plugin parser behavior
tests/integration/format/index.test.ts Updates existing test and adds new test case for module handling
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.

Copy link

netlify bot commented Sep 30, 2025

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit 94910a7
🔍 Latest deploy log https://app.netlify.com/projects/rslib/deploys/68db7560f07b7a0008ea1879
😎 Deploy Preview https://deploy-preview-1260--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant