Skip to content

Fix/npm-pkg-shared-backend - #1598

Merged
mantrakp04 merged 2 commits into
devfrom
fix/npm-pkg-shared-backend
Jun 15, 2026
Merged

mantrakp04 merged 2 commits into
devfrom
fix/npm-pkg-shared-backend

Conversation

@mantrakp04

@mantrakp04 mantrakp04 commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary by cubic

Prepares @hexclave/shared-backend for npm publishing with a proper build, dual ESM/CJS exports, and bundled types. Also simplifies an import parsing helper for safer matching.

  • New Features

    • Configure build with tsdown; output CJS/ESM and .d.ts to dist/ and dist/esm/.
    • Add export map for . and ./config-agent with require and default entries plus types.
    • Update publish settings: set main/types to built files, include only dist, exclude tests, and add build, dev, clean scripts.
    • Add repository field and tsdown.config.ts.
  • Bug Fixes

    • Simplified import specifier parsing in src/index.ts to push matches directly and remove unnecessary error throwing.

Written for commit 9f18bc0. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

Release Notes

  • Chores
    • Transitioned package to distribute pre-compiled artifacts from the build directory
    • Added build and development tooling scripts for package maintenance
    • Implemented conditional module exports for improved CommonJS and ESM compatibility

@vercel

vercel Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
stack-auth-hosted-components Building Building Preview, Comment Jun 15, 2026 11:35pm
stack-auth-internal-tool Ready Ready Preview, Comment Jun 15, 2026 11:35pm
stack-auth-mcp Building Building Preview, Comment Jun 15, 2026 11:35pm
stack-auth-skills Building Building Preview, Comment Jun 15, 2026 11:35pm
stack-backend Ready Ready Preview, Comment Jun 15, 2026 11:35pm
stack-dashboard Ready Ready Preview, Comment Jun 15, 2026 11:35pm
stack-demo Ready Ready Preview, Comment Jun 15, 2026 11:35pm
stack-docs Building Building Preview, Comment Jun 15, 2026 11:35pm
stack-preview-backend Ready Ready Preview, Comment Jun 15, 2026 11:35pm
stack-preview-dashboard Building Building Preview, Comment Jun 15, 2026 11:35pm

@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6bb79d33-5f8c-499a-a6b8-7a32042b860d

📥 Commits

Reviewing files that changed from the base of the PR and between 47b9a3a and 9f18bc0.

📒 Files selected for processing (3)
  • packages/shared-backend/package.json
  • packages/shared-backend/src/index.ts
  • packages/shared-backend/tsdown.config.ts

📝 Walkthrough

Walkthrough

@hexclave/shared-backend is converted from a source-referenced private package to a publishable built package. A new tsdown.config.ts wires the shared JS library build factory, package.json gains conditional CJS/ESM/types exports pointing to dist/, build/clean/dev scripts, and a files whitelist. A minor simplification removes a null-check and error throw in getRelativeImportSpecifiers.

Changes

shared-backend Build Pipeline and Publication Setup

Layer / File(s) Summary
tsdown config and package.json build pipeline
packages/shared-backend/tsdown.config.ts, packages/shared-backend/package.json
Adds tsdown.config.ts using the shared createJsLibraryTsupConfig factory. Updates package.json to replace source-based main/types/exports with conditional dist entries for CJS (dist/index.js), ESM (dist/esm/index.js), and types (dist/index.d.ts) for both . and ./config-agent subpaths. Removes private: true and type: "module". Adds build, clean, and dev scripts, and a files whitelist covering dist (excluding test files), CHANGELOG.md, and LICENSE.
Simplify import specifier extraction
packages/shared-backend/src/index.ts
Removes the explicit null-check and error throw for the regex capture group in getRelativeImportSpecifiers, directly appending match[1] to the specifiers array.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • N2D4

Poem

🐇 Hop hop, the dist is built at last,
No more raw .ts in the package cast!
CJS and ESM, both ready to ship,
tsdown takes the wheel on this little trip.
Private no more — the bunny says publish! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/npm-pkg-shared-backend

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.

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR promotes @hexclave/shared-backend from a private monorepo-internal package to a publishable npm package, aligning it with the pattern already used by @hexclave/shared.

  • package.json: Removes "private": true and "type": "module", replaces source-file main/types/exports pointers with dist/ build outputs, adds build/clean/dev scripts, a files list, and a dual CJS+ESM exports map — identical in structure to @hexclave/shared.
  • tsdown.config.ts: Adds the minimal tsdown build config by delegating to the existing shared createJsLibraryTsupConfig helper.
  • src/index.ts: Removes a dead null-check on match[1] in getRelativeImportSpecifiers; the capture group in the regex is non-optional so the check could never fire.

Confidence Score: 5/5

Safe to merge — the changes faithfully replicate the existing publishable-package pattern from @hexclave/shared, and the only source-code edit is removing dead code that could never execute.

All three changes are low-risk: the package.json restructuring mirrors the already-working @hexclave/shared layout, the new tsdown config delegates to a proven shared helper with no custom options, and the removed null-check in src/index.ts was guarding a condition the regex structure makes impossible.

No files require special attention.

Important Files Changed

Filename Overview
packages/shared-backend/package.json Converts from private monorepo-only package to publishable npm package; aligns exports map, main/types fields, and scripts with the established @hexclave/shared pattern.
packages/shared-backend/src/index.ts Removes a dead null-check on match[1]; since the capture group in the regex is non-optional, match[1] is always a defined string when the regex matches.
packages/shared-backend/tsdown.config.ts New minimal tsdown build config, delegating to the shared createJsLibraryTsupConfig helper, consistent with other publishable packages in the repo.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Consumer requires/imports @hexclave/shared-backend] --> B{Resolution condition}
    B -->|require CJS| C["dist/index.js (CJS)"]
    B -->|import ESM / default| D["dist/esm/index.js (ESM)"]
    B -->|TypeScript types| E["dist/index.d.ts"]

    F[Source: src/index.ts\nsrc/config-agent.ts\netc.] -->|tsdown build| G[dist/ — CJS output]
    F -->|tsdown build| H[dist/esm/ — ESM output]
    F -->|tsdown build| I[dist/*.d.ts — type declarations]

    G --> C
    H --> D
    I --> E
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Consumer requires/imports @hexclave/shared-backend] --> B{Resolution condition}
    B -->|require CJS| C["dist/index.js (CJS)"]
    B -->|import ESM / default| D["dist/esm/index.js (ESM)"]
    B -->|TypeScript types| E["dist/index.d.ts"]

    F[Source: src/index.ts\nsrc/config-agent.ts\netc.] -->|tsdown build| G[dist/ — CJS output]
    F -->|tsdown build| H[dist/esm/ — ESM output]
    F -->|tsdown build| I[dist/*.d.ts — type declarations]

    G --> C
    H --> D
    I --> E
Loading

Reviews (1): Last reviewed commit: "chore: update package.json to exclude te..." | Re-trigger Greptile

This branch was successfully deployed

5 active deployments
Preview – stack-preview-backend — 9f18bc01 Deployed Jun 15, 2026 by vercel[bot]
Preview – stack-preview-dashboard — 9f18bc01 Deployed Jun 15, 2026 by vercel[bot]
Preview – stack-auth-internal-tool — 9f18bc01 Deployed Jun 15, 2026 by vercel[bot]
Preview – stack-auth-mcp — 9f18bc01 Deployed Jun 15, 2026 by vercel[bot]
Preview – stack-auth-skills — 9f18bc01 Deployed Jun 15, 2026 by vercel[bot]
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