Sergi Jajanidze
Selected Work

High-traffic Bank of Georgia public site, 3 min read

Design system runtime integration

Moved the design system and framework runtime out of three application bundles and onto a CDN, resolved by the browser from one import map. A design-system upgrade became a version bump in one JSON file.

The problem

After the split into three independently deployed apps, all three depended on the same design system and framework runtime. Built into each application, those dependencies made up most of every bundle, and custom elements can only be registered once per page, so the apps needed one shared copy at runtime.

The approach

Shared dependencies became webpack externals that compile to bare specifiers, and an import map injected at build time tells the browser which version-pinned URL each one resolves to.

DiagramThree builds, one import map, one runtime copy
   shell        retail       business      three independent builds
     │             │             │
     └─────────────┼─────────────┘             shared packages stay bare imports
                   ▼
   import map: package name → version-pinned CDN URL
                   ▼
   browser module loader: one copy, shared by all three apps

Key decisions

Generating externals from the map

The import map is a checked-in JSON file, and the shell's webpack config derives its externals from the map's keys, so the two stay in sync.

JavaScriptwebpack.config.js, simplified
const { imports } = require("./import-map.json");
const names = Object.keys(imports);

// A plain name matches exactly; a name ending in "/" matches every subpath
const isShared = (request) =>
  names.some((name) =>
    name.endsWith("/") ? request.startsWith(name) : request === name,
  );

module.exports = {
  experiments: { outputModule: true },
  externalsType: "module",
  // Shared packages stay bare imports for the browser to resolve
  externals: ({ request }, callback) =>
    isShared(request) ? callback(null, request) : callback(),
};

Upgrades without rebuilding three apps

An upgrade is a version bump in the map. Non-production builds can also point the design system at its release-candidate channel behind a flag, so QA can sign off in the deployed test app with no extra build.

Treating the CDN as critical

Once every app shares the runtime, it is as critical as the site itself, and it's hosted that way. The packages live on the bank's own CDN rather than a public one, the shell modulepreloads the runtime so it downloads alongside the HTML, and version-pinned URLs are cached for a year. Returning visitors don't touch the CDN again until the next upgrade.

Integrity

Every URL in the map is version-pinned and immutable, and the build writes a subresource-integrity hash for each one into the map's integrity field. Browsers that support it refuse a file whose hash doesn't match; older browsers ignore the field.

Impact

Gzipped JavaScript per app on first load
AppBefore (KB)After (KB)Change
Shell412158−62%
Retail368141−62%
Business351139−60%
Shared runtime, from the CDN—236loaded once

Measuredwebpack-bundle-analyzer's gzipped sizes for each production build, on the same commit with and without the externals. The runtime row is the transferred size in Chrome DevTools with the cache disabled.

  • Per-application bundles shrank by about 60% compared with building the design system and framework runtime into each app.

    Measuredwebpack-bundle-analyzer's gzipped totals for each app, on the same commit built with and without the externals.

  • Those dependencies load from the CDN, are shared by all three apps, and stay cached across app deploys.
  • A design-system upgrade is a one-file version bump, validated in the deployed test app.

Trade-offs

What it cost

  • All three apps now share one runtime dependency, so how it is hosted and cached became part of every app's reliability.
  • Bare imports aren't tree-shaken: every app loads whole design-system packages, including components it never renders.
  • Every design-system upgrade makes returning visitors download the whole runtime again.

What I’d change

  • Publish per-component entry points, so apps load only what they render.
  • Open the version-bump pull request automatically when the design system releases.

Connected work

These case studies are parts of one platform. This one connects to: