Conversation
chenjiahan
commented
Mar 15, 2026
- Convert to pure ESM package
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request modernizes the project by transitioning its entire codebase to use ECMAScript Modules (ESM). This foundational change impacts how modules are defined, imported, and exported, and is reflected across the package configuration, build scripts, source code, and test infrastructure. The update aims to align the project with contemporary JavaScript standards and improve maintainability. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully converts the package to a pure ESM module. The changes are comprehensive, covering everything from package.json configuration and dependency updates to refactoring the source code to use ES modules syntax. The test suite and configuration files have also been updated accordingly. I have one suggestion regarding some redundant JSDoc comments in the generated type definition files that could be cleaned up for better maintainability.
There was a problem hiding this comment.
Pull request overview
This PR migrates @rspack/dev-middleware from CommonJS to ESM, updates the published TypeScript declaration files accordingly, and adjusts tests/fixtures/build tooling to run in an ESM package context.
Changes:
- Convert
src/**modules (middleware + utils) fromrequire/module.exportsto ESMimport/export. - Update
types/**declarations fromexport =patterns toexport default+ explicit exported types. - Migrate tests/fixtures/helpers to ESM and update build/test configuration (switch build to
rslib, addrstestretries).
Reviewed changes
Copilot reviewed 52 out of 65 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| types/utils/setupWriteToDisk.d.ts | Switch to export default + explicit exported type aliases. |
| types/utils/setupOutputFileSystem.d.ts | Switch to export default + explicit exported type aliases. |
| types/utils/setupHooks.d.ts | Switch to export default + explicit exported type aliases. |
| types/utils/ready.d.ts | Switch to export default + explicit exported type aliases. |
| types/utils/parseTokenList.d.ts | Switch to export default export style. |
| types/utils/memorize.d.ts | Switch to export default and export helper types. |
| types/utils/getPaths.d.ts | Switch to export default + explicit exported type aliases. |
| types/utils/getFilenameFromUrl.d.ts | Switch to export default + export Extra type. |
| types/utils/etag.d.ts | Switch to export default + explicit exported type aliases. |
| types/utils/escapeHtml.d.ts | Switch to export default export style. |
| types/middleware.d.ts | Switch to export default and export SendErrorOptions and related types. |
| types/index.d.ts | Rework primary public typings to ESM default export + exported types and wrapper namespace exports. |
| test/utils/setupWriteToDisk.test.js | Update imports to ESM and refine write-to-disk tests (incl. real FS test). |
| test/utils/setupOutputFileSystem.test.js | Update imports to ESM and simplify assertions around default fs behavior. |
| test/utils/setupHooks.test.js | Update imports to ESM and adjust async scheduling assertions. |
| test/utils/ready.test.js | Update import path to ESM (.js). |
| test/utils/escapeHtml.test.js | Update import path to ESM (.js). |
| test/utils/snapshots/setupWriteToDisk.test.js.snap | Update snapshots after test behavior changes. |
| test/middleware.test.js | Convert to ESM imports, avoid fixed ports, and update framework wiring. |
| test/helpers/runner.js | Convert CLI helper to ESM and dynamic import() for fixtures. |
| test/helpers/getCompiler.js | Convert helper to ESM and update fixture import path. |
| test/fixtures/webpack.watch-options.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.warning.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-verbose.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-true.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-object.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-none.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-minimal.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-false.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-colors-true.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.stats-colors-false.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.simple.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.querystring.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.public-path.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.no-stats.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.immutable.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.error.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.config.js | Convert fixture config to ESM export default. |
| test/fixtures/webpack.client.server.config.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.watch-options.config.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.warning.config.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.one-error-one-warning-one-success.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.one-error-one-warning-one-success-with-names.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.one-error-one-warning-one-object.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.one-error-one-warning-one-no.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.error.config.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.dev-server-false.js | Convert fixture config array to ESM export default. |
| test/fixtures/webpack.array.config.js | Convert fixture config array to ESM export default. |
| test/fixtures/foo.js | Convert fixture entry to ESM import statements. |
| src/utils/setupWriteToDisk.js | Convert util to ESM imports and export default. |
| src/utils/setupOutputFileSystem.js | Convert util to ESM imports and adjust memfs filesystem creation logic. |
| src/utils/setupHooks.js | Convert util export to export default. |
| src/utils/ready.js | Convert util export to export default. |
| src/utils/parseTokenList.js | Convert util export to export default. |
| src/utils/memorize.js | Convert util export to export default. |
| src/utils/getPaths.js | Convert util export to export default. |
| src/utils/getFilenameFromUrl.js | Convert util to ESM imports and export default. |
| src/utils/etag.js | Convert util to ESM imports and export default. |
| src/utils/escapeHtml.js | Convert util export to export default. |
| src/utils/compatibleAPI.js | Convert to named ESM exports. |
| src/middleware.js | Convert middleware to ESM imports/exports and refactor to static imports for some helpers. |
| src/index.js | Convert package entry to ESM imports and export default. |
| rstest.config.mjs | Add test retries. |
| pnpm-lock.yaml | Update lockfile for dependency/tooling changes (remove Babel deps, add rslib). |
| package.json | Mark package as ESM (type: module) and switch build to rslib. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| "name": "@rspack/dev-middleware", | ||
| "version": "7.4.5", | ||
| "type": "module", |
| const consoleLogSpy = rs.spyOn(globalThis.console, "log").mockImplementation(); | ||
|
|
||
| const __dirname = import.meta.dirname; | ||
|
|
||
| afterAll(() => { |
| import path from "node:path"; | ||
|
|
||
| const path = require('path'); | ||
| const __dirname = import.meta.dirname; | ||
|
|
||
| module.exports = { | ||
| export default { | ||
| mode: 'development', | ||
| context: path.resolve(__dirname), |
| import memfs, { Volume, createFsFromVolume } from "memfs"; | ||
|
|
||
| /** @typedef {import("@rspack/core").MultiCompiler} MultiCompiler */ |
| testEnvironment: "node", | ||
| globals: true, | ||
| testTimeout: 20000, | ||
| retry: 2, |