fix(perps-controller): restore webpackIgnore comment stripped by ts-bridge#8424
Merged
abretonc7s merged 1 commit intomainfrom Apr 10, 2026
Merged
fix(perps-controller): restore webpackIgnore comment stripped by ts-bridge#8424abretonc7s merged 1 commit intomainfrom
abretonc7s merged 1 commit intomainfrom
Conversation
Contributor
Author
|
@metamaskbot publish-previews |
ts-bridge's getDynamicImportExtensionTransformer creates new AST nodes that discard leading comments from the original source. This causes the `/* webpackIgnore: true */` magic comment on the MYXProvider dynamic import to be stripped from built dist files, resulting in a hard MODULE_NOT_FOUND error when consumed by webpack (extension). Fix by extracting the import path into a variable. ts-bridge only transforms string literal arguments in import() calls, so a variable reference is left untouched — preserving both the magic comment and the original path.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit be7ca59. Configure here.
be7ca59 to
dff83af
Compare
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Open
7 tasks
aganglada
approved these changes
Apr 10, 2026
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
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.

Explanation
When
@metamask/perps-controllerv2.0.0 is consumed by the MetaMask extension, webpack throws a hardMODULE_NOT_FOUNDerror on the MYXProvider dynamic import.Root cause:
ts-bridge'sgetDynamicImportExtensionTransformercreates new AST nodes (factory.createStringLiteral) that discard leading comments from the original source. The/* webpackIgnore: true */magic comment added in #8398 is present in TypeScript source but stripped from the compiled.mjs/.cjsoutput.Fix: Extract the import path into a local variable.
ts-bridgeonly transforms string literal arguments inimport()calls, so a variable reference is left untouched — preserving both the magic comment and the original path. This avoids needing post-build scripts or build system modifications (which would violate monorepo yarn constraints).Long-term: The proper fix is upstream in
@ts-bridge/cli— the transformer should copy leading comments from original nodes to synthesized ones viats.setSyntheticLeadingComments(). Once that's fixed, this workaround can be reverted.References
Changelog
@metamask/perps-controllerFixed
/* webpackIgnore: true */magic comment in built dist files by using a variable for the MYXProvider dynamic import path, preventing ts-bridge from rewriting the AST node and stripping the commentChecklist
dist/PerpsController.mjsanddist/PerpsController.cjsboth contain/* webpackIgnore: true */Note
Low Risk
Low risk change limited to how
MYXProvideris dynamically imported and documented in the changelog. Main risk is unintended bundler behavior if the import path variable affects tree-shaking/code-splitting in consuming builds.Overview
Ensures the
MYXProviderdynamic import retains the/* webpackIgnore: true */magic comment in compiled output by moving the import specifier to amyxModulePathvariable, avoidingts-bridgerewriting that strips the comment.Updates the perps-controller changelog to document this fix.
Reviewed by Cursor Bugbot for commit dff83af. Bugbot is set up for automated code reviews on this repo. Configure here.