Skip to content

Clarify TypeScript module resolution requirements#379

Merged
yamcodes merged 9 commits into
mainfrom
378-typescript-type-errors-when-using-module-commonjs-in-tsconfig
Nov 17, 2025
Merged

Clarify TypeScript module resolution requirements#379
yamcodes merged 9 commits into
mainfrom
378-typescript-type-errors-when-using-module-commonjs-in-tsconfig

Conversation

@yamcodes

@yamcodes yamcodes commented Nov 17, 2025

Copy link
Copy Markdown
Owner

Closes #378

Summary by CodeRabbit

  • New Features

    • Added a Bun playground: project scaffold, TypeScript config, development/build scripts, and a simple runnable example.
  • Documentation

    • Expanded quickstart with TypeScript moduleResolution guidance (including bundler option) and updated arkenv README with moduleResolution recommendations and caveats.
  • Chores

    • Added repository ignores for the new playground and excluded the playground from the main workspace.

…nd a new bun playground entry

- Added association for tsconfig.json to be recognized as jsonc.
- Introduced a new playground entry for bun in the workspace settings.
- Created .gitignore to exclude unnecessary files and directories.
- Added bun.lock for dependency management.
- Introduced index.ts with a simple console log.
- Configured package.json with scripts for development and build.
- Added README.md for project instructions.
- Set up tsconfig.json for TypeScript configuration.
- Included a Cursor rule for using Bun instead of Node.js and related tools.
- Updated TypeScript configuration to use ESNext features and improved module resolution.
- Enabled strict type-checking options and added best practices for TypeScript development.
- Removed outdated comments and organized settings for better clarity and maintainability.
- Added a new configuration option for `moduleResolution` in the TypeScript example.
- Included important notes on module resolution requirements for ArkEnv, emphasizing the need for modern strategies to avoid type errors.
- Clarified the implications of using older module resolution strategies.
- Added detailed instructions for modern TypeScript module resolution strategies in the README.
- Emphasized the necessity of using supported module resolution options to avoid potential issues.
- Retained information on compatibility with Node.js LTS and Bun versions.
- Clarified the requirement for modern TypeScript module resolution in the quickstart guide.
- Replaced the previous emphasis on specific module resolution strategies with a more flexible approach, allowing omission of `moduleResolution` under certain conditions.
- Enhanced the documentation to guide users towards best practices for configuring their TypeScript projects with ArkEnv.
- Introduced new dependencies for the Bun playground, including arkenv@0.7.5 and arktype@2.1.26.
- Added devDependencies for Bun, including typescript@5.9.3 and @types/bun@1.3.2.
- Updated pnpm-lock.yaml to reflect these changes and ensure proper dependency resolution.
@changeset-bot

changeset-bot Bot commented Nov 17, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 53af3cf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Nov 17, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Nov 17, 2025 9:11pm

@github-actions github-actions Bot added docs Adds or changes documentation, or acts as documentation in and of itself arkenv Changes to the `arkenv` npm package. example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory) www Improvements or additions to arkenv.js.org labels Nov 17, 2025
@coderabbitai

coderabbitai Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a new Bun playground at apps/playgrounds/bun/ with project files, examples and tooling guidance; updates TypeScript moduleResolution guidance in docs and workspace filings to accommodate bundler/node16/nodenext settings.

Changes

Cohort / File(s) Summary
Bun playground
apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc, apps/playgrounds/bun/.gitignore, apps/playgrounds/bun/README.md, apps/playgrounds/bun/index.ts, apps/playgrounds/bun/package.json, apps/playgrounds/bun/tsconfig.json
New Bun example/playground: Cursor rule doc for using Bun, gitignore, README with install/run instructions, hello-world index.ts, package.json with Bun scripts/deps, and modern TS config (ESNext + bundler).
Examples TypeScript config
examples/with-bun/tsconfig.json
Replaced commented defaults with an explicit, modern TS config: ESNext target/lib, moduleResolution: "bundler", react-jsx, strict checks enabled, noEmit true, and selective opt-outs.
Docs and package guidance
apps/www/content/docs/quickstart.mdx, packages/arkenv/README.md
Expanded quickstart and arkenv README to document moduleResolution options (bundler, node16/nodenext) and guidance for TypeScript setup.
Workspace & workspace exclude
arkenv.code-workspace, pnpm-workspace.yaml
Added Bun playground folder entry and tsconfig file association; excluded apps/playgrounds/bun from pnpm workspace.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Mixed changes: new example project, multiple config files, and docs.
  • Review focus: TS config semantics (moduleResolution), package.json scripts/deps, and the Cursor rule content.
  • Files to inspect closely: apps/playgrounds/bun/tsconfig.json, examples/with-bun/tsconfig.json, packages/arkenv/README.md, and pnpm-workspace.yaml.

Possibly related PRs

Poem

🐰 I hopped into a Bun-filled glade,
Created scripts where hops are made,
TS tuned for bundler skies,
A tiny index prints hello—hi! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Multiple changes go beyond issue #378's core scope: new Bun playground setup files, workspace configuration updates, and pnpm workspace changes are not directly related to resolving TypeScript module resolution type errors. Remove out-of-scope changes (Bun playground files, workspace entries) and focus the PR on resolving the TypeScript module resolution issue and documentation as defined in issue #378.
Title check ❓ Inconclusive The title 'Clarify TypeScript module resolution requirements' is vague and doesn't accurately reflect the main objective, which is to fix TypeScript type errors caused by specific module resolution strategies and the package.json exports configuration. Consider a more specific title that directly addresses the core issue, such as 'Fix TypeScript type errors with Node10/CommonJS module resolution' or 'Add exports field to package.json for proper type resolution'.
Linked Issues check ❓ Inconclusive The PR adds TypeScript configurations recommending 'bundler' and 'node16'/'nodenext' moduleResolution and documents this guidance, partially addressing issue #378's requirement to recommend modern module resolution strategies. Verify that package.json exports have been updated to specify types for both ESM and CommonJS conditions, which is the stated solution in issue #378 for fixing the root cause of type resolution failures.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 378-typescript-type-errors-when-using-module-commonjs-in-tsconfig

📜 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 6f53894 and 53af3cf.

⛔ Files ignored due to path filters (1)
  • apps/playgrounds/bun/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • apps/playgrounds/bun/package.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/playgrounds/bun/package.json
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-e2e (e2e)
🔇 Additional comments (1)
pnpm-workspace.yaml (1)

5-5: Correct exclusion pattern for the new Bun playground.

This change appropriately excludes the new apps/playgrounds/bun package from the pnpm workspace, following the existing pattern established for bun-react on line 6. Playgrounds are typically excluded to avoid dependency resolution conflicts and keep them as isolated projects.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arkenv-bot

arkenv-bot Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Package Size Limit Diff Status
arkenv 708 B 2 kB 0.0%

All size limits passed!

- Deleted Bun playground dependencies from pnpm-lock.yaml, including arkenv@0.7.5 and arktype@2.1.26.
- Updated pnpm-workspace.yaml to exclude the Bun playground from the workspace packages.
- Ensured that the pnpm-lock.yaml reflects the removal of unused dependencies for better maintenance.
@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/arkenv@379
npm i https://pkg.pr.new/@arkenv/vite-plugin@379

commit: 53af3cf

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/playgrounds/bun/package.json (1)

19-19: Consider pinning @types/bun to a specific version.

Using "latest" for @types/bun can lead to unpredictable builds as types may change between installations. Consider pinning to a specific version for reproducibility.

-    "@types/bun": "latest",
+    "@types/bun": "^1.3.2",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ef1677 and 6f53894.

⛔ Files ignored due to path filters (2)
  • apps/playgrounds/bun/bun.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc (1 hunks)
  • apps/playgrounds/bun/.gitignore (1 hunks)
  • apps/playgrounds/bun/README.md (1 hunks)
  • apps/playgrounds/bun/index.ts (1 hunks)
  • apps/playgrounds/bun/package.json (1 hunks)
  • apps/playgrounds/bun/tsconfig.json (1 hunks)
  • apps/www/content/docs/quickstart.mdx (1 hunks)
  • arkenv.code-workspace (2 hunks)
  • examples/with-bun/tsconfig.json (1 hunks)
  • packages/arkenv/README.md (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).

Applied to files:

  • apps/playgrounds/bun/README.md
  • apps/playgrounds/bun/package.json
  • apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc
  • arkenv.code-workspace
  • apps/www/content/docs/quickstart.mdx
  • packages/arkenv/README.md
📚 Learning: 2025-09-10T19:35:18.179Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 136
File: .changeset/vast-bananas-win.md:2-3
Timestamp: 2025-09-10T19:35:18.179Z
Learning: The arkenv package is currently in v0.x.x (pre-1.0) development phase, where breaking changes are acceptable in minor version bumps according to semantic versioning conventions.

Applied to files:

  • packages/arkenv/README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-e2e (a11y)
  • GitHub Check: test-e2e (e2e)
🔇 Additional comments (10)
arkenv.code-workspace (1)

5-5: LGTM! Workspace configuration updated appropriately.

The file association for tsconfig.json as JSONC enables comment support, and the new Bun playground folder is properly registered in the workspace.

Also applies to: 50-53

apps/playgrounds/bun/README.md (1)

1-15: LGTM! Clear and concise playground documentation.

The README provides straightforward setup and usage instructions appropriate for a playground environment.

apps/playgrounds/bun/index.ts (1)

1-1: LGTM! Minimal playground entry point.

This simple console output serves as an appropriate starting point for testing and development in the Bun playground.

packages/arkenv/README.md (1)

113-117: Excellent clarification of TypeScript module resolution requirements!

The expanded guidance clearly explains the supported moduleResolution options (bundler, node16/nodenext) and provides helpful warnings about unsupported strategies. The specific guidance for commonjs users addresses a common pain point. This aligns perfectly with the PR objectives.

apps/www/content/docs/quickstart.mdx (1)

17-30: Excellent documentation enhancement for TypeScript configuration!

The updated guidance clearly explains modern module resolution requirements, provides specific configuration options, and includes a helpful tip about when moduleResolution can be omitted. This complements the README changes and provides a consistent developer experience.

apps/playgrounds/bun/.gitignore (1)

1-34: LGTM! Comprehensive ignore patterns for Bun project.

The .gitignore includes all standard patterns for dependencies, build outputs, environment files, and IDE artifacts appropriate for a Bun-based playground.

apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc (1)

1-111: LGTM! Comprehensive Cursor AI rules for Bun development.

This rule file provides excellent guidance for developers working in the Bun playground, covering command substitutions, API preferences, testing patterns, and frontend setup with practical examples.

apps/playgrounds/bun/package.json (1)

11-11: The pnpm -w run fix pattern is intentional and consistent across all playgrounds.

Verification confirms that all playgrounds (Vite, Node, and Bun) use the identical pnpm -w run fix script. This is a deliberate monorepo workspace management pattern, not an inconsistency specific to Bun. The approach is correct and requires no changes.

Likely an incorrect or invalid review comment.

apps/playgrounds/bun/tsconfig.json (1)

1-29: TypeScript configuration appropriate for Bun bundler environment.

The configuration correctly uses "moduleResolution": "bundler" with "module": "Preserve" and "moduleDetection": "force", which is the right setup for bundler-based TypeScript projects. The settings allow TypeScript to work with modern bundlers like Bun while preserving the original module syntax for the bundler to handle.

Well-organized sections and clear comments make this configuration maintainable. The strict type-checking baseline with selective opt-outs for development ergonomics is a solid foundation.

Verify that related documentation updates in quickstart.mdx and arkenv/README.md adequately explain why developers should use "moduleResolution": "bundler" in Bun projects, especially when transitioning from "commonjs" or "node" resolution strategies. This will ensure the PR fully achieves its objective of clarifying module resolution requirements.

examples/with-bun/tsconfig.json (1)

3-24: Example configuration modernized for clarity and consistency.

Replacing commented defaults with explicit compiler options makes the configuration more maintainable and serves as a clearer reference for developers. The alignment with the new playground configuration (apps/playgrounds/bun/tsconfig.json) reinforces consistent module resolution practices across Bun examples.

This modernization supports the PR's objective of clarifying TypeScript module resolution requirements—developers can now see exactly what's needed for Bun without having to guess which defaults apply.

Verify that existing code in the examples/with-bun/ project (index.ts, components, tests, etc.) still works correctly with these explicit compiler options. Additionally, consider whether other example projects in the repository (e.g., with-vite-react-ts, if present) should receive similar explicit configuration updates for consistency. Per learnings, runtime support documentation should link to specific examples—ensure this example is clearly referenced in the updated documentation.

- Changed arkenv dependency from a file reference to version 0.7.5 in bun.lock.
- Updated @types/bun from latest to version ^1.3.2 in package.json.
- Ensured bun.lock reflects the latest dependency versions for better consistency.
@yamcodes
yamcodes merged commit 621bcc5 into main Nov 17, 2025
19 checks passed
@yamcodes
yamcodes deleted the 378-typescript-type-errors-when-using-module-commonjs-in-tsconfig branch November 17, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arkenv Changes to the `arkenv` npm package. docs Adds or changes documentation, or acts as documentation in and of itself example Issues or Pull Requests concerning at least one ArkEnv example. (Found in the `examples/` directory) www Improvements or additions to arkenv.js.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript type errors when using moduleResolution: "Node10" or "Node" in tsconfig

1 participant