Skip to content

Fixing package.json module paths and remove helpers#295

Closed
phillipc wants to merge 2 commits intomainfrom
pc/fix_repackaging
Closed

Fixing package.json module paths and remove helpers#295
phillipc wants to merge 2 commits intomainfrom
pc/fix_repackaging

Conversation

@phillipc
Copy link
Copy Markdown
Member

@phillipc phillipc commented Apr 12, 2026

  • Fixing the repackage script to conditionally include "helpers/" based on its existence.
  • Fix the "module" entry in multiple package.json files to point to "dist/index.js" instead of specific binding files.

Summary by CodeRabbit

  • Chores
    • Standardized package ESM entry points to a single index file for all packages.
    • Simplified package exports by removing secondary ./helpers/* subpath mappings.
    • Reduced published package footprint by removing the helpers directory from distributions.
    • Packaging now conditionally includes helpers only when that directory exists.

- Fixing  the repackage script to conditionally include "helpers/" based on its existence.
- Fix the "module" entry in multiple package.json files to point to "dist/index.js" instead of specific binding files.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: be3f3e68-7f9b-4534-a70d-fc56c4dc6402

📥 Commits

Reviewing files that changed from the base of the PR and between 9eea85e and 1aba4c8.

📒 Files selected for processing (1)
  • packages/computed/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/computed/package.json

📝 Walkthrough

Walkthrough

Updated many package.json files to standardize ESM entrypoints to dist/index.js, remove helpers/ from published files, and drop ./helpers/* subpath exports. The repackage tool now conditionally includes helpers entries only if a helpers/ directory exists.

Changes

Cohort / File(s) Summary
Binding Packages
packages/bind/package.json, packages/binding.component/package.json, packages/binding.core/package.json, packages/binding.foreach/package.json, packages/binding.if/package.json, packages/provider.databind/package.json
Set moduledist/index.js, removed helpers/ from files, removed ./helpers/* subpath export.
Binding Template
packages/binding.template/package.json
Set moduledist/index.js (no helpers changes shown).
Provider Packages
packages/provider/package.json, packages/provider.attr/package.json, packages/provider.bindingstring/package.json, packages/provider.component/package.json, packages/provider.multi/package.json, packages/provider.mustache/package.json, packages/provider.native/package.json, packages/provider.virtual/package.json
Set moduledist/index.js, removed helpers/ from files, removed ./helpers/* subpath export.
Utility Packages
packages/utils.component/package.json, packages/utils.functionrewrite/package.json, packages/utils.jsx/package.json, packages/utils.parser/package.json
Set moduledist/index.js, removed helpers/ from files, removed ./helpers/* subpath export.
Core & Builds
packages/builder/package.json, packages/computed/package.json, packages/filter.punches/package.json, packages/lifecycle/package.json, packages/observable/package.json, builds/reference/package.json
Removed helpers/ from files and removed ./helpers/* export; some also updated moduledist/index.js.
Build Tooling
tools/repackage.mjs
Detects presence of helpers/ directory and conditionally adds helpers/ to files and ./helpers/* to exports only when present.

Sequence Diagram(s)

sequenceDiagram
    participant Tool as tools/repackage.mjs
    participant FS as Filesystem
    participant PKG as package.json (output)
    Tool->>FS: check existence of "helpers/" (fs.access)
    FS-->>Tool: hasHelpers? (true/false)
    Tool->>Tool: build packageData (include helpers when true)
    Tool->>PKG: write package.json with conditional "files" and "exports"
    PKG-->>Tool: ack
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Pc/switch module resolution #289: Modifies tools/repackage.mjs logic related to package.json generation (types/exports handling), closely related to the conditional helpers inclusion in this change.

Suggested reviewers

  • brianmhunt
  • dvHuett
  • M-Kirchhoff

Poem

🐰 I hopped through package trees tonight,

tucked helpers safe out of sight,
exports trimmed, indices set,
tidy bundles—no regret. 🥕

🚥 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 accurately reflects the main changes: updating module paths to dist/index.js and removing helpers directory references from package.json files.
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 pc/fix_repackaging

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
packages/observable/package.json (1)

9-19: ⚠️ Potential issue | 🟠 Major

Add a changeset for the exported surface change.

Removing ./helpers/* changes public import behavior. Please include a .changeset entry documenting affected packages and bump type.

Based on learnings: Applies to .changeset/** : Create changeset files with npx changeset add for PRs that change package behavior to document affected packages, bump type, and describe changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/observable/package.json` around lines 9 - 19, The package export
change removed the "./helpers/*" public surface, so add a changeset file
documenting this export removal and the package(s) affected: run npx changeset
add (or create a .changeset/*.md file) naming the package(s) in
packages/observable, set an appropriate bump type (minor or patch per your
release policy — use minor if this is a breaking export change), and include a
short description that the "./helpers/*" exports were removed and how consumers
should migrate; ensure the changeset is committed under .changeset/.
packages/utils.parser/package.json (1)

32-38: ⚠️ Potential issue | 🟠 Major

Add a changeset entry to document the removal of the ./helpers/* public export from utils.parser.

Lines 32-38 remove the ./helpers/* public subpath export, which is a breaking API change. This package behavior change must be documented in a changeset file using npx changeset add to track the affected package, semver bump type, and changes for release notes. No changeset entry was found for this change.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/utils.parser/package.json` around lines 32 - 38, This change removes
the public subpath export "./helpers/*" from the utils.parser package which is a
breaking API change; add a changeset by running npx changeset add and select the
utils.parser package, describe that "./helpers/*" subpath export was removed,
and set the semver bump to major (breaking change) so release notes and
versioning reflect the removal.
packages/provider.bindingstring/package.json (1)

27-33: ⚠️ Potential issue | 🟠 Major

Create a changeset entry to document the breaking removal of the ./helpers/* export.

The ./helpers/* export was removed from the package exports (previously defined as "./helpers/*": "./helpers/*"). This is a breaking change for any consumers importing @tko/provider.bindingstring/helpers/*. Add a changeset entry using npx changeset add to document this package behavior change before merge.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/provider.bindingstring/package.json` around lines 27 - 33, Add a
Changeset documenting the breaking removal of the "./helpers/*" export from the
package; run `npx changeset add`, choose the package corresponding to
provider.bindingstring (packages/provider.bindingstring), mark the change as a
breaking change, describe that the `./helpers/*` export was removed and
consumers importing `@tko/provider.bindingstring/helpers/*` must update imports
or restore helpers, and save the generated markdown changeset file before
merging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/binding.foreach/package.json`:
- Around line 5-9: The package.json was changed to alter the published
entrypoints ("module": "dist/index.js" and "files": ["dist/","types/"]) and this
is a public packaging change that requires a Changeset; run npx changeset add
and create a .changeset/*.md entry documenting the package
(packages/binding.foreach) with a description of the breaking/public change and
the appropriate version bump (patch/minor/major as applicable) so the change
will be published and tracked; ensure the changeset file names the package and
the change type, and commit the new .changeset/*.md file alongside the
package.json change.

In `@tools/repackage.mjs`:
- Around line 10-11: The helper function hasDir currently treats any fs.access
error as "not present" which hides permission/IO errors; update hasDir to only
return false for a missing path (e.g., err.code === 'ENOENT') and rethrow any
other errors so permission/IO problems fail fast. Locate the hasDir function and
change its promise rejection handler to inspect err.code and return false only
for ENOENT (optionally ENOTDIR if desired), otherwise throw or reject the
original error instead of returning false.

---

Outside diff comments:
In `@packages/observable/package.json`:
- Around line 9-19: The package export change removed the "./helpers/*" public
surface, so add a changeset file documenting this export removal and the
package(s) affected: run npx changeset add (or create a .changeset/*.md file)
naming the package(s) in packages/observable, set an appropriate bump type
(minor or patch per your release policy — use minor if this is a breaking export
change), and include a short description that the "./helpers/*" exports were
removed and how consumers should migrate; ensure the changeset is committed
under .changeset/.

In `@packages/provider.bindingstring/package.json`:
- Around line 27-33: Add a Changeset documenting the breaking removal of the
"./helpers/*" export from the package; run `npx changeset add`, choose the
package corresponding to provider.bindingstring
(packages/provider.bindingstring), mark the change as a breaking change,
describe that the `./helpers/*` export was removed and consumers importing
`@tko/provider.bindingstring/helpers/*` must update imports or restore helpers,
and save the generated markdown changeset file before merging.

In `@packages/utils.parser/package.json`:
- Around line 32-38: This change removes the public subpath export "./helpers/*"
from the utils.parser package which is a breaking API change; add a changeset by
running npx changeset add and select the utils.parser package, describe that
"./helpers/*" subpath export was removed, and set the semver bump to major
(breaking change) so release notes and versioning reflect the removal.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2242e0fd-c366-4a71-af8f-6179fab85385

📥 Commits

Reviewing files that changed from the base of the PR and between df6e083 and 9eea85e.

📒 Files selected for processing (26)
  • builds/reference/package.json
  • packages/bind/package.json
  • 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/builder/package.json
  • packages/computed/package.json
  • packages/filter.punches/package.json
  • packages/lifecycle/package.json
  • packages/observable/package.json
  • 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
  • packages/utils.component/package.json
  • packages/utils.functionrewrite/package.json
  • packages/utils.jsx/package.json
  • packages/utils.parser/package.json
  • tools/repackage.mjs

Comment on lines +5 to 9
"module": "dist/index.js",
"files": [
"dist/",
"helpers/",
"types/"
],
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether this PR includes a changeset describing affected packages.
fd -e md . .changeset
rg -n '@tko/(binding\.foreach|filter\.punches|provider\.multi|utils\.component|binding\.component|provider\.mustache|utils\.functionrewrite|binding\.core)' .changeset

Repository: knockout/tko

Length of output: 527


🏁 Script executed:

#!/bin/bash
# List all files in .changeset directory to identify actual changeset entries
ls -lah .changeset/ | grep -v "^d" | grep -v "^total"
# Also count markdown files (excluding README)
find .changeset -maxdepth 1 -name "*.md" -type f ! -name "README.md" | wc -l
# Show any markdown files that are not README
find .changeset -maxdepth 1 -name "*.md" -type f ! -name "README.md"

Repository: knockout/tko

Length of output: 179


Add a changeset entry for this public packaging change.

This PR removes previously published/importable helpers and changes package entrypoint metadata across multiple packages. Create a .changeset/*.md file using npx changeset add to document the affected packages and bump type.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/binding.foreach/package.json` around lines 5 - 9, The package.json
was changed to alter the published entrypoints ("module": "dist/index.js" and
"files": ["dist/","types/"]) and this is a public packaging change that requires
a Changeset; run npx changeset add and create a .changeset/*.md entry
documenting the package (packages/binding.foreach) with a description of the
breaking/public change and the appropriate version bump (patch/minor/major as
applicable) so the change will be published and tracked; ensure the changeset
file names the package and the change type, and commit the new .changeset/*.md
file alongside the package.json change.

Comment thread tools/repackage.mjs
Comment on lines +10 to +11
const hasDir = (name) =>
fs.access(name).then(() => true, () => false)
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the current implementation swallows all fs.access errors
rg -n -C3 "const hasDir|fs\\.access\\(name\\)\\.then\\(\\(\\) => true, \\(\\) => false\\)" tools/repackage.mjs

Repository: knockout/tko

Length of output: 263


🏁 Script executed:

#!/bin/bash
# Find all usages of hasDir in the file
rg -n "hasDir" tools/repackage.mjs

Repository: knockout/tko

Length of output: 129


🏁 Script executed:

#!/bin/bash
# Get context around line 52 to see how hasHelpers is used
sed -n '48,65p' tools/repackage.mjs

Repository: knockout/tko

Length of output: 451


🏁 Script executed:

#!/bin/bash
# Get the packageData function implementation
sed -n '13,35p' tools/repackage.mjs

Repository: knockout/tko

Length of output: 568


Do not treat every fs.access error as "directory missing".

This currently converts permission/IO errors into false, which silently excludes the helpers directory from package exports and files metadata instead of failing fast.

Suggested fix
-const hasDir = (name) =>
-  fs.access(name).then(() => true, () => false)
+const hasDir = async (name) => {
+  try {
+    await fs.access(name)
+    return true
+  } catch (error) {
+    if (error?.code === 'ENOENT') return false
+    throw error
+  }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const hasDir = (name) =>
fs.access(name).then(() => true, () => false)
const hasDir = async (name) => {
try {
await fs.access(name)
return true
} catch (error) {
if (error?.code === 'ENOENT') return false
throw error
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/repackage.mjs` around lines 10 - 11, The helper function hasDir
currently treats any fs.access error as "not present" which hides permission/IO
errors; update hasDir to only return false for a missing path (e.g., err.code
=== 'ENOENT') and rethrow any other errors so permission/IO problems fail fast.
Locate the hasDir function and change its promise rejection handler to inspect
err.code and return false only for ENOENT (optionally ENOTDIR if desired),
otherwise throw or reject the original error instead of returning false.

brianmhunt pushed a commit that referenced this pull request Apr 14, 2026
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>
@brianmhunt
Copy link
Copy Markdown
Member

Superseded by #308 which applies these fixes (module paths + helpers removal + repackage.mjs deletion) cleanly to current main. Thanks for identifying the issue @phillipc.

@brianmhunt brianmhunt closed this Apr 15, 2026
@phillipc phillipc deleted the pc/fix_repackaging branch April 26, 2026 05:51
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