Minor Issue
Upgrading @finos/fdc3 from 2.1.x to 2.2.3 grew our minified ESM bundle by 181 KB.
Marking @finos/* as sideEffects: false at resolve time in our bundler narrowed the
regression to 158 KB but didn't fix it — the remainder is structural (see details below).
Area of Issue
Issue Description
Importing only getAgent / fdc3Ready from @finos/fdc3 pulls in the entire
@finos/fdc3-schema runtime (~240 KB), even when the consumer never references
BrowserTypes or BridgingTypes.
Root cause
@finos/fdc3-schema/dist/src/index.js:
import * as BrowserTypes from '../generated/api/BrowserTypes.js';
import * as BridgingTypes from '../generated/bridging/BridgingTypes.js';
export { BrowserTypes, BridgingTypes };
The import * as namespace binding is opaque to bundlers — any reachability of
BrowserTypes retains the whole module. The two generated modules are ~146 KB and
~94 KB of quicktype output (Convert classes plus type-guard helpers).
The umbrella @finos/fdc3 then re-exports both namespaces, so any consumer that imports
from it makes the schema reachable:
// @finos/fdc3/dist/src/index.js
import { BrowserTypes, BridgingTypes } from '@finos/fdc3-schema';
export { BridgingTypes, BrowserTypes };
Within @finos/fdc3-get-agent, the modules that introduce a runtime import of
fdc3-schema (and therefore force it into any reachable graph) are:
strategies/HelloHandler
strategies/IdentityValidationHandler
ui/AbstractUIComponent
ui/DefaultDesktopAgentChannelSelector
ui/DefaultDesktopAgentIntentResolver
(@finos/fdc3-agent-proxy/listeners/PrivateChannelEventListener is in the same
position.)
Options for cutting it down
-
Add "sideEffects": false to every @finos/* package. None of the six 2.2.3
packages declare it today.
-
Replace import * as with named re-exports in
@finos/fdc3-schema/dist/src/index.js so bundlers can drop symbols at export-name
granularity instead of keeping the entire 146 KB / 94 KB namespaces because
anything in them was reached.
-
Add an exports map with sub-paths to @finos/fdc3-schema so consumers can
opt in to the narrowest slice (e.g. types vs. validators) without bundlers having
to prove the rest is unused.
-
Split the generated Convert class out of the type-only exports. Most of the
240 KB is the Convert runtime (162 static methods on BrowserTypes alone) plus
its type-guard helpers. Consumers wanting only TypeScript types pay the full
runtime cost. A separate entry point for validators would let consumers that don't
need runtime schema validation skip it entirely.
Additional Context
Minor Issue
Upgrading
@finos/fdc3from 2.1.x to 2.2.3 grew our minified ESM bundle by 181 KB.Marking
@finos/*assideEffects: falseat resolve time in our bundler narrowed theregression to 158 KB but didn't fix it — the remainder is structural (see details below).
Area of Issue
Issue Description
Importing only
getAgent/fdc3Readyfrom@finos/fdc3pulls in the entire@finos/fdc3-schemaruntime (~240 KB), even when the consumer never referencesBrowserTypesorBridgingTypes.Root cause
@finos/fdc3-schema/dist/src/index.js:The
import * asnamespace binding is opaque to bundlers — any reachability ofBrowserTypesretains the whole module. The two generated modules are ~146 KB and~94 KB of quicktype output (
Convertclasses plus type-guard helpers).The umbrella
@finos/fdc3then re-exports both namespaces, so any consumer that importsfrom it makes the schema reachable:
Within
@finos/fdc3-get-agent, the modules that introduce a runtime import offdc3-schema (and therefore force it into any reachable graph) are:
strategies/HelloHandlerstrategies/IdentityValidationHandlerui/AbstractUIComponentui/DefaultDesktopAgentChannelSelectorui/DefaultDesktopAgentIntentResolver(
@finos/fdc3-agent-proxy/listeners/PrivateChannelEventListeneris in the sameposition.)
Options for cutting it down
Add
"sideEffects": falseto every@finos/*package. None of the six 2.2.3packages declare it today.
Replace
import * aswith named re-exports in@finos/fdc3-schema/dist/src/index.jsso bundlers can drop symbols at export-namegranularity instead of keeping the entire 146 KB / 94 KB namespaces because
anything in them was reached.
Add an
exportsmap with sub-paths to@finos/fdc3-schemaso consumers canopt in to the narrowest slice (e.g. types vs. validators) without bundlers having
to prove the rest is unused.
Split the generated
Convertclass out of the type-only exports. Most of the240 KB is the
Convertruntime (162 static methods onBrowserTypesalone) plusits type-guard helpers. Consumers wanting only TypeScript types pay the full
runtime cost. A separate entry point for validators would let consumers that don't
need runtime schema validation skip it entirely.
Additional Context