Skip to content

Conversation

@mondoreale
Copy link
Contributor

@mondoreale mondoreale commented Jan 9, 2026

This pull request updates the autocertifier-client package to provide separate builds and type definitions for Node.js and browser environments, and refactors how the SERVICE_ID constant is exported. The changes improve compatibility, allow for better tree-shaking, and clarify the package's entry points for different platforms.

Note

This adds a very minimalistic set of features used by browser bundles of other packages.

Changes

Multi-platform build and exports:

  • The package.json now defines separate entry points and type definitions for Node.js (exports-nodejs.*) and browser (exports-browser.*) builds, and introduces an exports map to clarify usage in different environments.

  • The Rollup configuration (rollup.config.mts) is updated to produce both Node.js and browser bundles and their corresponding type definitions, using separate output files for each platform. [1] [2] [3] [4]

Exports and type improvements:

  • A new exports-browser.ts file is added to explicitly export SERVICE_ID, CertifiedSubdomain, and AutoCertifierClient types for browser consumers.

  • The main exports.ts file now imports SERVICE_ID from a new consts.ts file, rather than directly from AutoCertifierClient.ts, improving modularity. [1] [2]

  • The SERVICE_ID constant is moved from AutoCertifierClient.ts to a new consts.ts module and is imported where needed, clarifying its source and reducing coupling. [1] [2] [3]

Minor improvements:

  • The DHT package updates its imports to use type-only imports for AutoCertifierClient, improving type safety and clarity.

  • Minor formatting cleanup in the DHT browser Rollup config.

Things to know

  • It may not be clear to the team that the Karma tests are a mixture of browser and NodeJS environments. Although Karma is meant to aim at the browser testing, there are 2 Karma setups now that explicitly point to NodeJS versions of other packages in order to work.

    1. trackerless-network points to NodeJS build of dht.
    2. dht points to NodeJS build of autocertifier-client.

    This does work, and is way easier to grasp if we talk about it openly and explicitly. And that's how the setups are now.

    We may want to address it as an issue in the future, and come up with much better separation though.

This is needed. We may also do that to `geoip-location` – maybe there's something interesting in it.
@mondoreale mondoreale requested a review from Copilot January 9, 2026 11:27
@github-actions github-actions bot added the dht Related to DHT package label Jan 9, 2026
@mondoreale mondoreale changed the title feat: Cross-browser cipher utils feat: Bundle a limited version of autocertifier-client for the browser Jan 9, 2026
Copy link
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 pull request adds browser support to the autocertifier-client package by introducing separate build outputs for Node.js and browser environments, and refactors the SERVICE_ID constant into a dedicated module for better code organization.

  • Adds browser-specific entry points with appropriate type definitions
  • Refactors SERVICE_ID export by extracting it to a new consts.ts module
  • Updates build configuration to generate separate bundles for Node.js and browser platforms

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/dht/src/browser/defaultAutoCertifierClientFactory.ts Changes import to type-only since AutoCertifierClient is only used for type annotation
packages/dht/rollup.config.mts Removes unnecessary blank line in browser build configuration
packages/autocertifier-client/src/exports.ts Refactors to import SERVICE_ID from new consts module
packages/autocertifier-client/src/exports-browser.ts New file providing browser-compatible exports (SERVICE_ID constant and type-only exports)
packages/autocertifier-client/src/consts.ts New file containing SERVICE_ID constant, extracted for better modularity
packages/autocertifier-client/src/AutoCertifierClient.ts Updates to import SERVICE_ID from consts module instead of exporting it directly
packages/autocertifier-client/rollup.config.mts Adds browser and browserTypes build functions to generate browser-specific bundles
packages/autocertifier-client/package.json Updates entry points and exports map to support both Node.js and browser environments

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

It's no more confusing than it used to be.
@mondoreale mondoreale merged commit aaa9278 into bundles Jan 9, 2026
21 checks passed
@mondoreale mondoreale deleted the autocertifier-client-mini-for-browser-envs branch January 9, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dht Related to DHT package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants