Skip to content

fix: should treat mjs and mts files as strict ES modules#818

Merged
9aoy merged 8 commits intomainfrom
type/javascript-esm
Dec 30, 2025
Merged

fix: should treat mjs and mts files as strict ES modules#818
9aoy merged 8 commits intomainfrom
type/javascript-esm

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Dec 30, 2025

Summary

Use rspack default behavior, treat mjs and mts files as strict ES modules.

https://rspack.rs/config/module-rules#rulestype

Related Links

web-infra-dev/rsbuild#5955

Checklist

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

Copilot AI review requested due to automatic review settings December 30, 2025 07:46
@netlify
Copy link
Copy Markdown

netlify bot commented Dec 30, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 9a4b93f
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/69539894be18c40008f69009
😎 Deploy Preview https://deploy-preview-818--rstest-dev.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.

Copy link
Copy Markdown
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 support for treating .mjs and .mts files as strict ES modules by configuring Rspack to use the javascript/esm module type for these file extensions.

Key changes:

  • Added a module rule in the Rspack configuration to handle .mjs and .mts files with the javascript/esm type
  • Added an e2e test to verify that .mjs files are properly handled
  • Updated snapshot tests to reflect the new module rule in the configuration

Reviewed changes

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

File Description
packages/core/src/core/plugins/basic.ts Adds a new module rule to treat .mjs and .mts files as strict ES modules using the javascript/esm type
packages/core/tests/core/__snapshots__/rsbuild.test.ts.snap Updates snapshots to include the new module rule configuration across all test scenarios
e2e/build/moduleType.test.mjs Adds a new e2e test file to verify that .mjs files are treated as ES modules
e2e/build/src/swc.js Adds a test fixture file using CommonJS syntax to test module interoperability

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

9aoy and others added 2 commits December 30, 2025 16:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@9aoy 9aoy requested a review from fi3ework December 30, 2025 08:01
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 30, 2025

📝 Rstest Ecosystem CI: Open

suite result
rsdoctor ✅ success
rslib ✅ success
rsbuild ✅ success
rspress ✅ success
modernjs ✅ success

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 30, 2025

📝 Rstest Ecosystem CI: Open

suite result
modernjs ✅ success
rslib ✅ success
rsbuild ✅ success
rspress ✅ success
rsdoctor ✅ success

@9aoy 9aoy merged commit db82fec into main Dec 30, 2025
16 checks passed
@9aoy 9aoy deleted the type/javascript-esm branch December 30, 2025 10:44
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.

2 participants