Skip to content

fix(build): bundle @noble into the IIFE build for browser/CDN consumers - #200

Merged
sherifahmed990 merged 1 commit into
devfrom
fix/iife-bundle-noble
Jun 9, 2026
Merged

fix(build): bundle @noble into the IIFE build for browser/CDN consumers#200
sherifahmed990 merged 1 commit into
devfrom
fix/iife-bundle-noble

Conversation

@Sednaoui

@Sednaoui Sednaoui commented Jun 9, 2026

Copy link
Copy Markdown
Member

The IIFE (unpkg) build externalized @noble/hashes and @noble/curves, emitting them as undefined globals (_noble_hashes_sha3, _noble_curves_secp256k1). Loading the script via a CDN/<script> tag threw ReferenceError: _noble_hashes_sha3 is not defined and window.abstractionkit was never defined. Bundles @noble/* into the IIFE (with platform: browser so its crypto shim uses Web Crypto, not node:crypto) while keeping it external for CJS/ESM. Also drops the dead ethers external config. Verified in headless Chrome.

Summary by CodeRabbit

  • Chores
    • Refactored build configuration to use multiple separate targets with shared settings for improved maintainability.
    • Enhanced browser compatibility for dependencies by adjusting resolution strategy.

The IIFE (unpkg) build externalized @noble/hashes and @noble/curves, emitting them as undefined globals (_noble_hashes_sha3, _noble_curves_secp256k1), so a <script>/CDN consumer hit 'ReferenceError: _noble_hashes_sha3 is not defined' and window.abstractionkit was never defined. Bundle @noble into the IIFE (platform: browser, so its crypto shim uses Web Crypto rather than node:crypto) while keeping it external for CJS/ESM so npm consumers dedupe a single copy. Drop the dead ethers external config (ethers is not a runtime import). Verified in headless Chrome: window.abstractionkit defined, keccak and secp256k1 paths work.
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e93a544-1d43-4739-b452-1a9692235732

📥 Commits

Reviewing files that changed from the base of the PR and between 1641550 and 79396a3.

📒 Files selected for processing (1)
  • tsdown.config.ts

📝 Walkthrough

Walkthrough

The build configuration file is refactored to support multiple output targets with shared settings. A base shared config contains common properties; the cjs/esm target inherits those and adds declaration and clean-build flags, while the iife target is independently configured for browser compatibility with explicit global naming and dependency handling.

Changes

Build configuration multi-target refactor

Layer / File(s) Summary
Multi-target configuration with shared base
tsdown.config.ts
Configuration migrated from single config to array-based format with shared settings for entry, sourcemap: false, and target: 'es2022'. The cjs/esm build inherits shared properties and adds dts: true and clean: true. The iife build is separated with globalName: 'abstractionkit', noExternal: [/^@noble\//], and platform: 'browser' for browser-compatible crypto resolution. Previous deps.neverBundle for ethers and outputOptions.globals removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • candidelabs/abstractionkit#90: Introduced the initial tsdown-based configuration; this PR refactors and extends it with multi-target support and browser-specific settings.

Poem

🐰 Multiple builds from one shared ground,
Library and browser, together they're bound,
Noble crypto flows safe through the browser's domain,
Clean declarations and iife magic reign!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: bundling @noble into the IIFE build for browser/CDN consumers.
Description check ✅ Passed The description provides context, explains the problem, documents the solution, and mentions verification, but lacks formal structure matching the template's Summary/Test/Risk sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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

@sherifahmed990 sherifahmed990 left a comment

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.

LGTM

@sherifahmed990
sherifahmed990 merged commit ed2937a into dev Jun 9, 2026
3 checks passed
@sherifahmed990
sherifahmed990 deleted the fix/iife-bundle-noble branch June 9, 2026 10:07
sherifahmed990 pushed a commit that referenced this pull request Jun 9, 2026
Follow-up to #200. The IIFE (unpkg) build targets <script>/CDN consumers, but that path is undocumented and unused -- abstractionkit consumers install via npm and use a bundler (ESM/CJS), both unaffected. Rather than maintain a second-class distribution (and ship a ~600 kB self-contained artifact) for a near-empty audience, remove the iife format and the unpkg field. CJS, ESM and type outputs are unchanged.
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