Skip to content

feat: cdn contract and stable subpath export. - #106

Merged
knightedcodemonkey merged 3 commits into
mainfrom
bananas
Aug 1, 2026
Merged

feat: cdn contract and stable subpath export.#106
knightedcodemonkey merged 3 commits into
mainfrom
bananas

Conversation

@knightedcodemonkey

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings August 1, 2026 18:26
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.14%. Comparing base (8ff8e63) to head (b3efb6f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
+ Coverage   88.90%   89.14%   +0.24%     
==========================================
  Files          26       27       +1     
  Lines        2199     2248      +49     
  Branches      623      637      +14     
==========================================
+ Hits         1955     2004      +49     
  Misses         71       71              
  Partials      173      173              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a generated CDN “contract” JSON and a stable helper subpath so consumers can programmatically build provider-specific (esm.sh / jsDelivr) URLs for the package’s stable entrypoints (core, react, transform).

Changes:

  • Introduces src/cdn-stable.ts with getStableCdnUrls / buildStableCdnUrls and contract loading logic.
  • Adds a generator script to produce cdn-contract.json, and wires it into prepack plus package exports.
  • Updates docs and the jsDelivr demo to use the new stable URL helper.

Reviewed changes

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

Show a summary per file
File Description
test/cdn-stable.test.ts Adds unit tests for URL building, contract loading, and error cases.
src/cdn-stable.ts Implements contract validation, provider URL generation, and contract loading helper.
scripts/generate-cdn-contract.mjs Generates cdn-contract.json from package.json dependency versions (with --check mode).
README.md Documents stable CDN usage and the published cdn-contract.json subpath.
package.json Exports ./cdn-stable and ./cdn-contract.json, adds generation/check scripts, updates prepack, bumps version.
package-lock.json Updates lockfile package version.
examples/esm-demo.html Switches demo imports to use getStableCdnUrls and stable entry URLs.
.gitignore Ignores generated cdn-contract.json in the repo workspace.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/generate-cdn-contract.mjs
Comment thread src/cdn-stable.ts
Comment thread src/cdn-stable.ts
Copilot AI review requested due to automatic review settings August 1, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/cdn-stable.ts:100

  • assertContract validates entry presence, but it doesn't validate contract-level fields or enforce a safe subpath shape. A malformed/remote contract can currently produce URLs like undefined@undefined///react or deps=name@ instead of failing fast. Consider validating packageName, packageVersion, entries and ensuring each entry subpath is either . or starts with ./, plus verifying all dependency versions are non-empty strings.
const assertContract = (contract: CdnContract) => {
  if (!contract || typeof contract !== 'object') {
    throw new Error('[cdn-stable] A valid contract object is required.')
  }

src/cdn-stable.ts:109

  • When cdn-contract.json is missing (which is likely in a clean repo checkout since it’s generated at prepack time), the file: branch throws the raw ENOENT/SyntaxError without context. Wrapping this with a more actionable error (and preserving the original as cause) will make failures easier to diagnose.
  if (contractUrl.protocol === 'file:') {
    const fs = await import('node:fs/promises')
    const content = await fs.readFile(contractUrl, 'utf8')
    return JSON.parse(content) as CdnContract
  }

@knightedcodemonkey
knightedcodemonkey merged commit bfed525 into main Aug 1, 2026
10 checks passed
@knightedcodemonkey
knightedcodemonkey deleted the bananas branch August 1, 2026 18:45
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