Skip to content

fix(kernel-ui): rationalize build externals and dependency declarations#652

Merged
sirtimid merged 3 commits intomainfrom
sirtimid/rationalize-externals
Oct 2, 2025
Merged

fix(kernel-ui): rationalize build externals and dependency declarations#652
sirtimid merged 3 commits intomainfrom
sirtimid/rationalize-externals

Conversation

@sirtimid
Copy link
Copy Markdown
Contributor

@sirtimid sirtimid commented Oct 1, 2025

Description

This PR rationalizes the build configuration and dependency declarations for the @metamask/kernel-ui package to make it a properly self-contained UI library.

Problem

The kernel-ui package had several configuration issues:

  • Externalized dependencies that should be bundled for easier consumption
  • Incorrectly declared peer dependencies
  • Included unused dependencies (ses)
  • TypeScript configs referenced packages that weren't actually used
  • Type-only dependencies were in dependencies instead of devDependencies

Solution

Build Configuration Changes

  • Bundle all dependencies except React: Changed from externalizing all MetaMask packages to bundling them, making kernel-ui truly self-contained
  • Only externalize React ecosystem: Now only react, react-dom, and JSX runtimes are external
  • Result: Bundle size increased from ~59KB to ~402KB, but consuming applications (like extension) now only need to provide React

Dependency Changes

  • Removed unused dependencies:
    • ses - not imported anywhere in the source code
  • Moved to devDependencies:
    • @metamask/ocap-kernel - only used for TypeScript type imports
  • Peer dependencies:
    • Now only react and react-dom (removed @metamask/design-system-react - it's bundled)

TypeScript Configuration Cleanup

  • Removed ses from types arrays in both tsconfig.json and tsconfig.build.json
  • Removed references to unused packages (@metamask/streams, @metamask/kernel-shims)

Impact

Simpler consumption: Applications using kernel-ui (like the extension popup) now only need to:

import '@metamask/kernel-ui/styles.css';
import { App } from '@metamask/kernel-ui';

Better dependency management: Clear separation between what's bundled vs what consumers must provide

Cleaner build: No warnings about missing dependencies, all depcheck issues resolved

Testing

  • Build passes successfully for kernel-ui
  • Extension builds and works with the updated kernel-ui
  • No linter errors
  • depcheck passes with no issues

Note

Kernel UI now bundles internal deps and only externals React (declared as peer), removes SES/types/references, and the extension build renames the _commonjsHelpers chunk.

  • Kernel UI:
    • Build: Bundle previously externalized packages; only externalize react, react-dom, and JSX runtimes in packages/kernel-ui/vite.config.ts.
    • Dependencies: Move react and react-dom to peerDependencies; remove react, react-dom, and ses from dependencies in packages/kernel-ui/package.json.
    • TypeScript: Remove ses from types arrays; drop unused references to @metamask/kernel-shims and @metamask/streams in tsconfig.json/tsconfig.build.json.
  • Extension:
    • Build: Customize chunkFileNames in packages/extension/vite.config.ts to rename _commonjsHelpers to commonjsHelpers.js.

Written by Cursor Bugbot for commit 85e7deb. This will update automatically on new commits. Configure here.

@sirtimid sirtimid requested a review from a team as a code owner October 1, 2025 14:15
cursor[bot]

This comment was marked as outdated.

@sirtimid sirtimid enabled auto-merge (squash) October 1, 2025 15:50
@sirtimid sirtimid requested a review from rekmarks October 2, 2025 10:34
Copy link
Copy Markdown
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sirtimid sirtimid merged commit 2d31089 into main Oct 2, 2025
23 checks passed
@sirtimid sirtimid deleted the sirtimid/rationalize-externals branch October 2, 2025 16:22
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