Skip to content

Fix broken module paths, remove helpers from published packages#308

Merged
brianmhunt merged 6 commits intomainfrom
fix/package-module-paths
Apr 15, 2026
Merged

Fix broken module paths, remove helpers from published packages#308
brianmhunt merged 6 commits intomainfrom
fix/package-module-paths

Conversation

@brianmhunt
Copy link
Copy Markdown
Member

@brianmhunt brianmhunt commented Apr 14, 2026

Summary

The module field in 22 package.json files pointed to non-existent files (e.g., dist/bind.js instead of dist/index.js). Any bundler using the module field for ESM resolution would get errors.

Also removes helpers/ from files and ./helpers/* from exports — test helpers shouldn't ship to npm consumers.

Based on @phillipc's work in PR #295, applied cleanly to current main (his branch was stale). PR #295 can be closed.

Changes

  • 22 packages: module field → dist/index.js
  • 27 packages: remove helpers/ from files array
  • 27 packages: remove ./helpers/* from exports

Test plan

  • make — 27 packages build
  • bunx vitest run — 2679 passed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Standardized package entry points across all packages
    • Removed previously exposed internal export paths to streamline package distribution

The module field in 22 package.json files pointed to non-existent
files (e.g. dist/bind.js). esbuild outputs dist/index.js.
Bundlers using the module field would get resolution errors.

Also remove helpers/ from files and exports — test helpers
shouldn't ship to npm consumers.

Based on phillipc's work in PR #295, applied cleanly to current main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 14, 2026 19:14
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

Warning

Rate limit exceeded

@brianmhunt has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 21 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 21 minutes and 21 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 30c72da5-47ea-4f6b-8182-ccdb2a089943

📥 Commits

Reviewing files that changed from the base of the PR and between 69f019b and 6621beb.

📒 Files selected for processing (9)
  • .changeset/fix-module-paths.md
  • Makefile
  • packages/bind/spec/crossWindowBehaviors.ts
  • packages/builder/package.json
  • packages/observable/package.json
  • packages/utils/package.json
  • tools/build.mk
  • tools/repackage.mjs
  • tsconfig.json
📝 Walkthrough

Walkthrough

The PR removes helpers/ directories from published package files and eliminates the ./helpers/* subpath export across 27 package.json files. Additionally, the module field is standardized to dist/index.js in all affected packages, and the build tool repackage.mjs is updated to conditionally include helpers based on directory existence.

Changes

Cohort / File(s) Summary
Build Packages
builds/knockout/package.json, builds/reference/package.json
Removed helpers/ from files array and eliminated ./helpers/* export subpath; root exports remain unchanged.
Binding Packages
packages/binding.component/package.json, packages/binding.core/package.json, packages/binding.foreach/package.json, packages/binding.if/package.json, packages/binding.template/package.json, packages/bind/package.json
Updated module field to dist/index.js, removed helpers/ from files, and eliminated ./helpers/* export subpath.
Provider Packages
packages/provider.attr/package.json, packages/provider.bindingstring/package.json, packages/provider.component/package.json, packages/provider.databind/package.json, packages/provider.multi/package.json, packages/provider.mustache/package.json, packages/provider.native/package.json, packages/provider.virtual/package.json, packages/provider/package.json
Updated module field to dist/index.js, removed helpers/ from files, and eliminated ./helpers/* export subpath.
Other Core Packages
packages/builder/package.json, packages/computed/package.json, packages/filter.punches/package.json, packages/lifecycle/package.json, packages/observable/package.json, packages/utils.component/package.json, packages/utils.functionrewrite/package.json, packages/utils.jsx/package.json, packages/utils.parser/package.json, packages/utils/package.json
Updated module field to dist/index.js, removed helpers/ from files, and eliminated ./helpers/* export subpath.
Build Tool
tools/repackage.mjs
Added hasDir() helper function and updated packageData() signature to accept hasHelpers parameter; made helpers/ exports and files entries conditional based on directory existence.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • dvHuett
  • M-Kirchhoff

Poem

🐰 The helpers hop away, whoosh!
From exports and files they fly,
Now index.js stands proud and tall,
Repackage rules apply!
Clean paths emerge from the bush,
Our packages simplified. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main changes: fixing broken module paths and removing helpers from published packages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/package-module-paths

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.

Without this, make repackage would re-add helpers/ to every
package.json. Now only includes helpers in exports/files if the
helpers directory actually exists.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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

This PR standardizes package ESM entrypoints and tightens the npm publish surface across the monorepo by correcting incorrect module paths and removing test helpers from exports/published files.

Changes:

  • Update module in multiple packages/*/package.json files to dist/index.js to avoid broken ESM resolution.
  • Remove helpers/ from files and remove ./helpers/* from exports across packages/builds so test helpers aren’t shipped to npm consumers.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/utils/package.json Stop publishing helpers/ and remove ./helpers/* export.
packages/utils.parser/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/utils.jsx/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/utils.functionrewrite/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/utils.component/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.virtual/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.native/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.mustache/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.multi/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.databind/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.component/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.bindingstring/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/provider.attr/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/observable/package.json Stop publishing helpers/ and remove ./helpers/* export.
packages/lifecycle/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/filter.punches/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/computed/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/builder/package.json Stop publishing helpers/ and remove ./helpers/* export.
packages/binding.template/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/binding.if/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/binding.foreach/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/binding.core/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/binding.component/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
packages/bind/package.json Fix module to dist/index.js; stop publishing/exporting helpers.
builds/reference/package.json Stop publishing helpers/ and remove ./helpers/* export.
builds/knockout/package.json Stop publishing helpers/ and remove ./helpers/* export.

"name": "@tko/bind",
"description": "TKO DOM-Observable Binding",
"module": "dist/bind.js",
"module": "dist/index.js",
Comment on lines 41 to +45
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
},
"./helpers/*": "./helpers/*"
}
Comment on lines 27 to +31
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js"
},
"./helpers/*": "./helpers/*"
}
Brian M Hunt and others added 4 commits April 14, 2026 15:26
- Add module: dist/index.js to @tko/observable, @tko/utils, @tko/builder
- Preserve existing exports.".".import extension in repackage.mjs
  (builds use .mjs, packages use .js — don't overwrite)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
binding.template has a legitimate test consumer
(crossWindowBehaviors.ts imports dummyTemplateEngine). Keep
./helpers/* in its exports. Add changeset for the module path fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dummyTemplateEngine is a test helper that should never ship to npm.
Change crossWindowBehaviors.ts to use a relative workspace path
instead of the package specifier. Remove the tsconfig path alias
since it's no longer needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
repackage.mjs overwrites per-package package.json with a template,
clobbering package-specific config and fighting against intentional
changes. Versioning is handled by Changesets, metadata consistency
can be validated by a lint rule if needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread tools/repackage.mjs
* the package.json files are consistent and it is
* easy to distribute changes.
*/
import fs from 'fs/promises'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I corrected the repackage.mjs file instead of deleting it.

That works too. Instead of a script, AI will automate this for us in 2026.

@phillipc
Copy link
Copy Markdown
Member

phillipc commented Apr 15, 2026

@brianmhunt Good restoration of my changes.

In https://github.com/knockout/tko/pull/289/changes#diff-32b7e790f9dfc6997466222d294b0bed74fc6ae2346a88d9e990a27f337fcd7cR1 - I have also fixed up the DTS generation for each package, but I had needed Knip before to correct the cycles in the type imports.

I had obtained external confirmation of the "Knip" merger, if one look closely. Unfortunately, you left me hanging for four months.

@brianmhunt brianmhunt merged commit af3cc31 into main Apr 15, 2026
5 checks passed
@brianmhunt brianmhunt deleted the fix/package-module-paths branch April 15, 2026 11:16
@brianmhunt
Copy link
Copy Markdown
Member Author

Thanks @phillipc -- appreciate your patience here.

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.

3 participants