Skip to content

fix: make compatible with moduleResolution=node*#185

Merged
dinwwwh merged 1 commit into
mainfrom
fix/node-module-resolution
Mar 1, 2025
Merged

fix: make compatible with moduleResolution=node*#185
dinwwwh merged 1 commit into
mainfrom
fix/node-module-resolution

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Mar 1, 2025

Summary by CodeRabbit

  • Refactor

    • Standardized module exports across packages by updating distribution file formats and type definitions to modern ECMAScript standards.
    • Simplified public interfaces to ensure cleaner integration and maintainability.
  • Chores

    • Replaced the previous build tool with a streamlined alternative.
    • Updated dependencies and inter-package references to better support a modern module-based structure.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 1, 2025 6:57am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 1, 2025

Walkthrough

This pull request transitions the project’s build process from using the tsup tool to unbuild. It updates export configurations across multiple package manifests by changing file extensions from .js/.d.ts to .mjs/.d.mts, and it removes legacy export entries (e.g., "./🔒/*"). In addition, several tsup.config.ts files have been removed and related build scripts simplified. A minor dependency (escape-string-regexp) has also been added in one package, and TypeScript configuration for the zod package has been improved with new compiler options and project references.

Changes

File(s) Change Summary
package.json (root) Removed the tsup dependency (^8.3.0) and added the unbuild dependency (^3.5.0) in devDependencies.
packages/**/package.json (client, contract, openapi, react-query, server, shared, standard-server-fetch, standard-server-node, standard-server, vue-colada, vue-query, zod) Updated publishConfig.exports and exports: file paths for types and modules changed from .d.ts/.js to .d.mts/.mjs; removed "./🔒/*" entries; replaced build scripts using tsup with unbuild. Additionally, in packages/zod/package.json, added dependency "escape-string-regexp": "^5.0.0".
packages/{client,openapi,server}/tsup.config.ts Deleted the configuration files for tsup, which previously defined build entry points and bundling options.
packages/zod/tsconfig.json Added a new compiler option "rootDir": "src" and added project references to ../contract, ../server, and ../shared.

Possibly related PRs

  • unnoq/orpc#179: Updates build scripts from tsup to unbuild and dependency changes, aligning with the overall toolchain transition.
  • unnoq/orpc#176: Also features changes in the build process by replacing tsup with unbuild in multiple package configurations.

Poem

I’m a rabbit on the run,
Hopping through code under the sun,
Tsup has hopped away—farewell and adieu,
Unbuild now leads our builds anew,
With paths renewed in .mjs style,
I nibble on changes with a joyful smile!
(^_^)/


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0e429d and 1042954.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (17)
  • package.json (1 hunks)
  • packages/client/package.json (1 hunks)
  • packages/client/tsup.config.ts (0 hunks)
  • packages/contract/package.json (1 hunks)
  • packages/openapi/package.json (2 hunks)
  • packages/openapi/tsup.config.ts (0 hunks)
  • packages/react-query/package.json (1 hunks)
  • packages/server/package.json (2 hunks)
  • packages/server/tsup.config.ts (0 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/standard-server-fetch/package.json (1 hunks)
  • packages/standard-server-node/package.json (1 hunks)
  • packages/standard-server/package.json (1 hunks)
  • packages/vue-colada/package.json (1 hunks)
  • packages/vue-query/package.json (1 hunks)
  • packages/zod/package.json (2 hunks)
  • packages/zod/tsconfig.json (1 hunks)
💤 Files with no reviewable changes (3)
  • packages/openapi/tsup.config.ts
  • packages/server/tsup.config.ts
  • packages/client/tsup.config.ts
🔇 Additional comments (54)
package.json (1)

44-47: Dependency Update: Added "unbuild"
The addition of "unbuild": "^3.5.0" in the devDependencies section replaces the previous reliance on tsup and aligns with the new build process based on the PR objectives. Make sure that any build scripts or configurations referencing tsup are updated across the project.

packages/zod/tsconfig.json (2)

3-5: Define Source Directory with "rootDir"
Adding "rootDir": "src" in compilerOptions explicitly sets the source directory, which improves TypeScript’s module resolution especially when using Node’s module resolution strategies.


7-10: Add Explicit Project References
The new references to "../openapi", "../contract", "../server", and "../shared" help TypeScript understand project dependencies. Please verify that these relative paths correctly point to the intended packages in the repository structure.

packages/react-query/package.json (3)

22-24: Modernize Export Paths for ES Modules
Updating the publishConfig.exports entries so that "types" points to ./dist/index.d.mts and both "import" and "default" point to ./dist/index.mjs ensures compatibility with ECMAScript module standards and Node’s resolution with moduleResolution=node*.


28-28: Exports Field Verification
The change to "exports": { ".": "./src/index.ts" } exposes the source entry point. Please verify that downstream consumers—especially those expecting built outputs—handle this mapping appropriately.


35-36: Build Script Transition to "unbuild"
Switching the build command from using tsup to "build": "unbuild" simplifies the configuration and is consistent with the new build approach outlined in the PR.

packages/contract/package.json (3)

18-21: Refactor Publish Configuration for ES Module Compatibility
Changing the export paths in publishConfig.exports so that "types" targets ./dist/index.d.mts and both "import" and "default" point to ./dist/index.mjs is a clear win for module compatibility under Node’s module system.


25-26: Simplify Exports Mapping
The export mapping of ".": "./src/index.ts" provides a straightforward entry point. It is advisable to double-check that this source mapping meets the consumers’ expectations, particularly if they rely on pre-transpiled modules.


32-33: Adopt "unbuild" in Build Scripts
Updating the build script to "build": "unbuild" ensures consistency across packages and aligns with the project's new tooling strategy.

packages/vue-colada/package.json (3)

23-26: Align Publish Config with Modern Module Standards
The update of the export paths—setting "types" to ./dist/index.d.mts and both "import" and "default" to ./dist/index.mjs—ensures that the package conforms to ECMAScript module expectations and Node’s resolution behavior when using moduleResolution=node*.


29-29: Verify Export Mapping for Source Entry
The "exports": { ".": "./src/index.ts" } entry is maintained to expose the source directly; please verify that downstream tooling or consumers can appropriately handle this unbundled export if needed.


36-39: Transition Build Script to "unbuild"
Replacing the previous build command with "build": "unbuild" standardizes and simplifies the build process across packages, ensuring consistency with the new workflow.

packages/zod/package.json (4)

17-23: Update publishConfig exports to use ECMAScript module extensions.
The export paths for types, import, and default have been updated to use .d.mts and .mjs extensions. This change ensures compatibility with Node’s ECMAScript module resolution.


25-27: Simplify main exports configuration.
The standalone "exports" section now points only to "./src/index.ts", streamlining the package’s public interface by removing legacy sub-paths.


31-33: Update build script to use unbuild.
The build script has been simplified from its previous tsup-based command to "unbuild", reflecting the new build process.


41-46: Add new dependency: escape-string-regexp.
The dependency "escape-string-regexp": "^5.0.0" has been added, which aligns with the updated module resolution strategy. Ensure that this addition is intentional and that its usage is properly scoped within the package.

packages/shared/package.json (3)

16-22: Update publishConfig exports for ECMAScript modules.
The export definitions now use the .d.mts and .mjs extensions. This update aligns with the new module resolution strategy and improves consistency across packages.


25-27: Simplify package exports.
By setting "." to "./src/index.ts", the export configuration is more concise, removing legacy or redundant entries.


31-35: Switch build script to unbuild.
Changing the build command to "unbuild" reflects a move away from the previous tsup configuration, thereby simplifying the build process.

packages/standard-server/package.json (3)

15-21: Revise publishConfig exports for modern module support.
The export paths have been updated to use .d.mts for types and .mjs for JavaScript modules, ensuring consistency with ECMAScript module standards.


24-26: Streamline the main export.
Changing the main export to point to "./src/index.ts" removes legacy sub-paths and simplifies the package’s interface.


30-33: Update the build command.
Switching to "unbuild" for the build script simplifies the build process and aligns with similar changes in other packages.

packages/standard-server-node/package.json (3)

15-21: Ensure export paths conform to new standards.
The publishConfig exports are now updated with .d.mts and .mjs extensions, which supports ECMAScript module resolution and improves compatibility.


24-26: Simplify the exports field.
Redefining the main export as "./src/index.ts" removes any legacy or unnecessary entries, thereby streamlining module resolution.


30-34: Adopt unbuild in the build script.
The build script change to "unbuild" simplifies the build process and is consistent with the updated workflow across packages.

packages/vue-query/package.json (3)

20-25: Refresh publishConfig exports to reflect module changes.
The paths for types, import, and default have been updated to use .d.mts and .mjs extensions. This change standardizes the module format across the project.


28-30: Simplify main export configuration.
The export field now directly points to "./src/index.ts", removing legacy sub-paths for a cleaner configuration.


34-38: Standardize build script update.
Updating the build script to "unbuild" removes the need for complex tsup commands and is consistent with the other packages’ configurations.

packages/standard-server-fetch/package.json (3)

18-20: ESM Export Configurations Updated

The publishConfig now uses ESM-specific file extensions (.d.mts for types and .mjs for module entry points). This change helps align with moduleResolution=node* and ECMAScript module standards. Please ensure that all downstream consumers and TypeScript configurations are updated accordingly.


25-25: Simplified Main Export Mapping

The exports field now maps the default export to "./src/index.ts". Confirm that this approach supports your project’s structure and that there are no unintended implications for module consumers.


31-31: Build Script Transitioned to Unbuild

The build script has switched from using tsup to the simpler unbuild command. Verify that the new build process produces the expected outputs and integrates correctly with your CI/CD pipeline.

packages/client/package.json (6)

19-21: Main Entry Exports Conformed to ESM

The primary export now correctly specifies types with .d.mts and both import and default with .mjs, ensuring consistency with ECMAScript modules.


24-26: OpenAPI Submodule Export Adjusted

The export configuration for the "./openapi" submodule has been updated to use .d.mts for type definitions and .mjs for module files. This is in line with the overall ESM transition.


29-31: RPC Exports Updated for ESM Compliance

The changes in the "./rpc" export now feature the updated file extensions necessary for proper module resolution in Node environments.


34-36: Fetch Adapter Export Now in ESM Format

The "./fetch" entry has been updated with .d.mts and .mjs extensions, aligning it with the project-wide move to ECMAScript modules.


44-44: Exports Field Consistency for Fetch Adapter

The exports mapping for "./fetch" now directly points to "./src/adapters/fetch/index.ts". Confirm that this mapping functions correctly with your build tool and runtime resolution.


50-50: Build Script Updated to Unbuild

Transitioning from tsup to unbuild simplifies the build command. Ensure that the output files are correctly structured and that the change is well-communicated to all team members.

packages/openapi/package.json (8)

19-21: Primary Export Now Uses ESM Extensions

The main export’s types, import, and default values have been updated to use .d.mts and .mjs, ensuring consistency with ECMAScript module conventions and improved compatibility with moduleResolution in Node.


24-26: Standard Adapter Export Updated

The "./standard" export configuration now correctly adopts the new ESM file extensions. This change supports the overall transition to a unified module format.


29-31: Fetch Adapter Export Conforms to ESM

The updated export configuration for "./fetch" reflects the necessary changes for ESM support. Double-check that dependent code is aware of these new file paths.


34-36: Hono Adapter Export Adjusted

The "./hono" export now points to .d.mts and .mjs files. This aligns well with the overall shift towards ECMAScript modules.


39-41: Next Adapter Export Converted

The changes here update the "./next" export to use ESM-compatible extensions. Ensure that any dynamic imports or references are updated accordingly.


44-46: Node Adapter Export Now ESM Compliant

The "./node" export has been updated to reflect .d.mts for types and .mjs for module entry points. This is key for compatibility with moduleResolution settings.


56-56: Exports Field Update for Node Adapter

The exports mapping for "./node" correctly points to the TypeScript source file. Verify that this new mapping works as intended across all environments.


62-62: Build Script Updated to Unbuild

Replacing the tsup command with unbuild in the scripts section simplifies the build process. Ensure that this change is tested across your development and CI environments.

packages/server/package.json (9)

19-21: Main Export Configured for ESM

The primary export within publishConfig now utilizes .d.mts for types and .mjs for module imports/exports, offering improved compatibility with Node’s module resolution.


24-26: Plugins Export Now ESM-Ready

The "./plugins" export has been updated to include the new file extensions. Confirm that plugins consuming this export are compatible with these changes.


29-31: Standard Adapter Export Updated

The "./standard" entry now uses ESM file extensions. This update helps standardize module formats across your packages.


33-36: Fetch Adapter Export Adapted for ESM

The fetch adapter’s export now aligns with the ECMAScript module standard by using .d.mts and .mjs extensions.


39-41: Hono Adapter Export Now ESM Compliant

The updated export for "./hono" properly reflects ESM conventions. This change is critical for ensuring moduleResolution works across Node environments.


43-46: Next Adapter Export Converted

The "./next" export now uses .d.mts and .mjs, ensuring that it meets the ECMAScript module criteria.


49-51: Node Adapter Export Updated for ESM

The "./node" export in publishConfig now uses the updated file extensions. This is important for consistency and future module resolution.


62-62: Exports Field for Node Adapter

The mapping for "./node" in the exports field points to the correct source file ("./src/adapters/node/index.ts"). Double-check that consumers resolve this as expected.


68-68: Build Script Transitioned to Unbuild

The build script update from tsup to unbuild simplifies the project’s build process. Confirm that this change does not introduce any regressions in the build outputs.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 1, 2025

Open in Stackblitz

More templates

@orpc/client

npm i https://pkg.pr.new/@orpc/client@185

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@185

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@185

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@185

@orpc/server

npm i https://pkg.pr.new/@orpc/server@185

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@185

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@185

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@185

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@185

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@185

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@185

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@185

commit: 1042954

@dinwwwh dinwwwh merged commit 84e58e0 into main Mar 1, 2025
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.

1 participant