Skip to content

refactor: migrate package runtime to ESM#91

Merged
chenjiahan merged 2 commits intomainfrom
chenjiahan/feat-esm-support
Apr 7, 2026
Merged

refactor: migrate package runtime to ESM#91
chenjiahan merged 2 commits intomainfrom
chenjiahan/feat-esm-support

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

@chenjiahan chenjiahan commented Apr 7, 2026

Summary

  • migrate the package and runtime helper files to native ESM semantics
  • update source imports, path resolution, release tooling, and workflow commands to use .js outputs consistently
  • adjust test fixtures and compilation helpers for ESM entries while keeping the existing refresh behavior covered

@chenjiahan chenjiahan marked this pull request as ready for review April 7, 2026 11:12
Copilot AI review requested due to automatic review settings April 7, 2026 11:12
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

Migrates the package and its injected runtime/client helpers to native ESM, updating build/test/release wiring to consistently use .js ESM outputs.

Changes:

  • Convert client runtime helper files (client/*) from CommonJS to ESM exports/imports.
  • Update source/runtime path resolution and internal TS imports to ESM-friendly semantics (.js extensions, createRequire, import.meta.dirname).
  • Refactor tests and fixtures to use ESM modules and async/await compilation flow; update release tooling/workflow commands.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/test.spec.ts Refactors compilation helper to return a Promise and migrates tests to async/await + ESM path handling.
test/fixtures/query/index.js Switches fixture entry to ESM import with explicit extension + query.
test/fixtures/query/foo.js Converts fixture module export to ESM default export.
test/fixtures/loader/loader.cjs Adds a CJS custom loader fixture to remain compatible with loader resolution.
test/fixtures/loader/index.js Converts fixture entry from require to ESM import.
test/fixtures/default/index.js Converts fixture entry/module to ESM.
test/fixtures/custom/index.js Converts fixture entry from require to ESM import.
src/paths.ts Updates runtime/client path resolution for ESM (import.meta.dirname, createRequire).
src/options.ts Minor formatting cleanup in option docs.
src/index.ts Updates internal imports to include .js extensions for NodeNext ESM output.
scripts/release.js Adjusts ESM-friendly URL-to-path handling for release script.
rslib.config.ts Introduces rslib build configuration (bundle + dts).
README.md Updates usage snippet and removes deprecated/extra config shown previously.
package.json Switches package to ESM (type: module) and updates export to dist/index.js; adjusts release script path.
client/refreshUtils.js Migrates refresh utils from CJS to ESM imports/exports.
client/reactRefreshEntry.js Migrates entry injection helper from CJS require to ESM import.
client/reactRefresh.js Migrates runtime wrapper from CJS to ESM exports and updates imports.
.github/workflows/release.yml Updates workflow to execute the new scripts/release.js entrypoint.

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bd8501652

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chenjiahan chenjiahan merged commit 84c7fb8 into main Apr 7, 2026
4 checks passed
@chenjiahan chenjiahan deleted the chenjiahan/feat-esm-support branch April 7, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants