Skip to content

Conversation

JSerFeng
Copy link

@JSerFeng JSerFeng commented Oct 16, 2025

Summary

Using EsmLibraryPlugin for better ESM output

Now you can use experiments.advancedEsm to enable new esm format.

Compared to the previous, this supports split chunk, and every single output chunk can easily statically analyzed if scope hoisted. Not use rspack runtime to load chunks anymore

Related Links

Checklist

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

@Copilot Copilot AI review requested due to automatic review settings October 16, 2025 03:09
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 introduces experimental support for better ESM output using Rspack's EsmLibraryPlugin and adds module type detection for TypeScript files. The changes enable a new experiments.advancedEsm configuration option that generates more static-analysis-friendly ESM output with code splitting support, while also implementing automatic detection of module types based on file extensions (.mts, .cts) and package.json type fields.

Key changes:

  • Added experiments.advancedEsm configuration option for enhanced ESM output format
  • Implemented module type detection for .mts (ESM) and .cts (CommonJS) file extensions
  • Updated test snapshots to reflect the new ESM output format with runtime chunks

Reviewed Changes

Copilot reviewed 50 out of 52 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
website/docs/*/config/lib/experiments.mdx Added documentation for the new experiments.advancedEsm configuration option
website/docs/*/config/lib/_meta.json Added experiments to documentation navigation
tests/scripts/shared.ts Updated generateBundleEsmConfig to enable advancedEsm by default
tests/package.json Reverted dependency version changes
tests/integration/**/index.test.ts Updated test snapshots to match new ESM output format
tests/integration/package-json/** Added test fixtures for package.json type field detection
packages/core/src/types/config.ts Added LibExperiments type definition with advancedEsm option
packages/core/src/config.ts Implemented EsmLibraryPlugin integration and module type detection logic
examples/**/rslib.config.ts Enabled advancedEsm in example configurations
packages/plugin-dts/package.json Reverted version changes
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.

@netlify
Copy link

netlify bot commented Oct 16, 2025

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit cbd24a3
🔍 Latest deploy log https://app.netlify.com/projects/rslib/deploys/68f77be7e58b380008e22d9c
😎 Deploy Preview https://deploy-preview-1273--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.

@Timeless0911 Timeless0911 marked this pull request as draft October 16, 2025 03:46
expect(entries.esm).toMatchInlineSnapshot(`
"import node_path from "node:path";
const { join } = node_path;
const { join: join } = node_path;
Copy link
Author

Choose a reason for hiding this comment

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

not sure why, I'm looking into it

@JSerFeng JSerFeng force-pushed the beta branch 2 times, most recently from 989d563 to a08d30c Compare October 16, 2025 12:03
@Timeless0911 Timeless0911 force-pushed the beta branch 2 times, most recently from 7b87c70 to f8e79f4 Compare October 20, 2025 07:52
@Timeless0911
Copy link
Contributor

Timeless0911 commented Oct 20, 2025

should check

  • examples folder
  • origin test cases
  • issue related to esm
  • esm issue repo
  • add new esm test cases

@Timeless0911
Copy link
Contributor

Timeless0911 commented Oct 20, 2025

  • runtime secondary consumption
image
  • mf lazy error
image

@Timeless0911 Timeless0911 force-pushed the beta branch 2 times, most recently from 54831e1 to caa2cd5 Compare October 21, 2025 03:14
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 21, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@rslib/core@1273
npm i https://pkg.pr.new/create-rslib@1273
npm i https://pkg.pr.new/rsbuild-plugin-dts@1273

commit: cbd24a3

@Timeless0911 Timeless0911 force-pushed the beta branch 2 times, most recently from 21c94da to 00be908 Compare October 21, 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.

3 participants