refactor: migrate package runtime to ESM#91
Conversation
There was a problem hiding this comment.
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 (
.jsextensions,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.
There was a problem hiding this comment.
💡 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".
Summary
.jsoutputs consistently