generated from MetaMask/metamask-module-template
-
Notifications
You must be signed in to change notification settings - Fork 7
refactor: Consolidate endoify setup and rationalize exension globals #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rekmarks
wants to merge
8
commits into
main
Choose a base branch
from
rekm/omnium-refactors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set globalThis.kernel in the extension and omnium to the kernel itself. Remove ping and getKernel methods from background console interface. The kernel exposes ping().
…helpers - Remove packages/nodejs/src/env/endoify.ts re-export, use @metamask/kernel-shims/node-endoify directly - Update vitest configs to use kernel-shims for setup files - Remove inline endoify imports from test files (now handled by vitest setup) - Fix test helpers to handle SubclusterLaunchResult return type from launchSubcluster() - Add kernel-shims dependency to kernel-test and nodejs-test-workers packages - Set coverage thresholds to 0 temporarily Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…e configs - Fix accidentally broken nodejs vat worker (which broke all tests relying on it) - Rename node-endoify.js to endoify-node.js for consistency - Update package.json export from ./node-endoify to ./endoify-node - Update all vitest configs to use the new export path - Update depcheckrc.yml ignore pattern Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The endoify-node export was pointing to src/endoify-node.js, but the files array only includes dist/, causing the file to be missing from published packages. The file cannot be bundled because it imports @libp2p/webrtc (a peer dependency), so the build script now copies it to dist/ instead. Changes: - Update build script to copy endoify-node.js to dist/ - Update package.json export to point to dist/endoify-node.js - Update source comment to reflect new build process Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Simplify the build script by using the built-in copyFile function instead of manually reading and writing the file. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR consolidates several refactoring improvements to improve code organization and reduce circular dependencies:
@ocap/nodejsto@metamask/kernel-shims/endoify-nodeMotivation
@ocap/nodejsand@metamask/kernel-shims, creating circular dependency patterns@ocap/nodejswhen it logically belongs in the shims packageglobalThis.kernelAPI had unnecessary wrapper methods (ping(),getKernel()) when a direct reference would sufficeChanges
Endoify consolidation
@metamask/kernel-shims/endoify-nodefor Node.js-specific lockdown initialization@ocap/nodejs/endoify-mjsand@ocap/nodejs/endoify-tsexports@metamask/kernel-shims/endoify-node@libp2p/webrtcas peer dependency to kernel-shims (imports before lockdown to modify globals)Global API rationalization
Before:
After:
This simplification:
E(globalThis.kernel).ping()instead ofkernel.ping()Dependency improvements
dist/directories (avoids false positives from build artifacts)@libp2p/webrtcto depcheck ignores (peer dependency of kernel-shims)@ocap/nodejsfrom@metamask/kernel-browser-runtimedevDependencies (was only used for test setup)Test plan
yarn test:dev:quietFiles changed
🤖 Generated with Claude Code
Note
Centralizes Node.js lockdown/init and streamlines extension globals.
@metamask/kernel-shims/endoify-node, copies it during build, and declares@libp2p/webrtcas a peer dependency; all Node.js tests/workers now import this shimendoifyexports from@ocap/nodejsand related imports; cleans up devDeps (e.g., drops@ocap/nodejsfromkernel-browser-runtimetests)globalThis.kerneltoKernelFacade | Promise<KernelFacade>and updates extension/omnium backgrounds to setglobalThis.kerneland useE(globalThis.kernel).ping(); updates type declarations accordinglydist/and@libp2p/webrtc; updates LavaMoat allowScripts entryWritten by Cursor Bugbot for commit b3afe55. This will update automatically on new commits. Configure here.