feat: Bundle a limited version of autocertifier-client for the browser
#3340
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request updates the
autocertifier-clientpackage to provide separate builds and type definitions for Node.js and browser environments, and refactors how theSERVICE_IDconstant 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.jsonnow defines separate entry points and type definitions for Node.js (exports-nodejs.*) and browser (exports-browser.*) builds, and introduces anexportsmap 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.tsfile is added to explicitly exportSERVICE_ID,CertifiedSubdomain, andAutoCertifierClienttypes for browser consumers.The main
exports.tsfile now importsSERVICE_IDfrom a newconsts.tsfile, rather than directly fromAutoCertifierClient.ts, improving modularity. [1] [2]The
SERVICE_IDconstant is moved fromAutoCertifierClient.tsto a newconsts.tsmodule 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 forAutoCertifierClient, 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.
trackerless-networkpoints to NodeJS build ofdht.dhtpoints to NodeJS build ofautocertifier-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.