Skip to content

fix(perps-controller): restore webpackIgnore comment stripped by ts-bridge#8424

Merged
abretonc7s merged 1 commit intomainfrom
feat/perps/sync-april-9th
Apr 10, 2026
Merged

fix(perps-controller): restore webpackIgnore comment stripped by ts-bridge#8424
abretonc7s merged 1 commit intomainfrom
feat/perps/sync-april-9th

Conversation

@abretonc7s
Copy link
Copy Markdown
Contributor

@abretonc7s abretonc7s commented Apr 10, 2026

Explanation

When @metamask/perps-controller v2.0.0 is consumed by the MetaMask extension, webpack throws a hard MODULE_NOT_FOUND error on the MYXProvider dynamic import.

Root cause: ts-bridge's getDynamicImportExtensionTransformer creates 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/.cjs output.

Fix: Extract the import path into a local 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. 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 via ts.setSyntheticLeadingComments(). Once that's fixed, this workaround can be reverted.

References

Changelog

@metamask/perps-controller

Fixed

  • Preserve /* 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 comment

Checklist

  • I've updated the changelog
  • I've verified the fix: dist/PerpsController.mjs and dist/PerpsController.cjs both contain /* webpackIgnore: true */
  • Tests pass
  • Changelog validates
  • Yarn constraints pass

Note

Low Risk
Low risk change limited to how MYXProvider is 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 MYXProvider dynamic import retains the /* webpackIgnore: true */ magic comment in compiled output by moving the import specifier to a myxModulePath variable, avoiding ts-bridge rewriting 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.

@abretonc7s abretonc7s requested review from a team as code owners April 10, 2026 10:38
@abretonc7s
Copy link
Copy Markdown
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.
Copy link
Copy Markdown

@cursor cursor bot left a 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.

Fix All in Cursor

❌ 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.

@abretonc7s abretonc7s force-pushed the feat/perps/sync-april-9th branch from be7ca59 to dff83af Compare April 10, 2026 10:48
@abretonc7s
Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.0.0-preview-dff83af4c
@metamask-previews/accounts-controller@37.2.0-preview-dff83af4c
@metamask-previews/address-book-controller@7.1.1-preview-dff83af4c
@metamask-previews/ai-controllers@0.6.3-preview-dff83af4c
@metamask-previews/analytics-controller@1.0.1-preview-dff83af4c
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-dff83af4c
@metamask-previews/announcement-controller@8.1.0-preview-dff83af4c
@metamask-previews/app-metadata-controller@2.0.1-preview-dff83af4c
@metamask-previews/approval-controller@9.0.1-preview-dff83af4c
@metamask-previews/assets-controller@5.0.0-preview-dff83af4c
@metamask-previews/assets-controllers@103.1.1-preview-dff83af4c
@metamask-previews/base-controller@9.0.1-preview-dff83af4c
@metamask-previews/base-data-service@0.1.1-preview-dff83af4c
@metamask-previews/bridge-controller@70.0.1-preview-dff83af4c
@metamask-previews/bridge-status-controller@70.0.5-preview-dff83af4c
@metamask-previews/build-utils@3.0.4-preview-dff83af4c
@metamask-previews/chain-agnostic-permission@1.5.0-preview-dff83af4c
@metamask-previews/claims-controller@0.5.0-preview-dff83af4c
@metamask-previews/client-controller@1.0.1-preview-dff83af4c
@metamask-previews/compliance-controller@2.0.0-preview-dff83af4c
@metamask-previews/composable-controller@12.0.1-preview-dff83af4c
@metamask-previews/config-registry-controller@0.2.0-preview-dff83af4c
@metamask-previews/connectivity-controller@0.2.0-preview-dff83af4c
@metamask-previews/controller-utils@11.20.0-preview-dff83af4c
@metamask-previews/core-backend@6.2.1-preview-dff83af4c
@metamask-previews/delegation-controller@2.1.0-preview-dff83af4c
@metamask-previews/earn-controller@11.2.1-preview-dff83af4c
@metamask-previews/eip-5792-middleware@3.0.3-preview-dff83af4c
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.0-preview-dff83af4c
@metamask-previews/eip1193-permission-middleware@1.0.3-preview-dff83af4c
@metamask-previews/ens-controller@19.1.1-preview-dff83af4c
@metamask-previews/eth-block-tracker@15.0.1-preview-dff83af4c
@metamask-previews/eth-json-rpc-middleware@23.1.1-preview-dff83af4c
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-dff83af4c
@metamask-previews/foundryup@1.0.1-preview-dff83af4c
@metamask-previews/gas-fee-controller@26.1.1-preview-dff83af4c
@metamask-previews/gator-permissions-controller@3.0.1-preview-dff83af4c
@metamask-previews/geolocation-controller@0.1.2-preview-dff83af4c
@metamask-previews/json-rpc-engine@10.2.4-preview-dff83af4c
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-dff83af4c
@metamask-previews/keyring-controller@25.2.0-preview-dff83af4c
@metamask-previews/logging-controller@8.0.1-preview-dff83af4c
@metamask-previews/message-manager@14.1.1-preview-dff83af4c
@metamask-previews/messenger@1.1.1-preview-dff83af4c
@metamask-previews/messenger-cli@0.1.0-preview-dff83af4c
@metamask-previews/money-account-controller@0.1.0-preview-dff83af4c
@metamask-previews/multichain-account-service@8.0.1-preview-dff83af4c
@metamask-previews/multichain-api-middleware@2.0.0-preview-dff83af4c
@metamask-previews/multichain-network-controller@3.0.6-preview-dff83af4c
@metamask-previews/multichain-transactions-controller@7.0.4-preview-dff83af4c
@metamask-previews/name-controller@9.1.1-preview-dff83af4c
@metamask-previews/network-controller@30.0.1-preview-dff83af4c
@metamask-previews/network-enablement-controller@5.0.2-preview-dff83af4c
@metamask-previews/notification-services-controller@23.0.1-preview-dff83af4c
@metamask-previews/permission-controller@12.3.0-preview-dff83af4c
@metamask-previews/permission-log-controller@5.1.0-preview-dff83af4c
@metamask-previews/perps-controller@2.0.0-preview-dff83af4c
@metamask-previews/phishing-controller@17.1.1-preview-dff83af4c
@metamask-previews/polling-controller@16.0.4-preview-dff83af4c
@metamask-previews/preferences-controller@23.1.0-preview-dff83af4c
@metamask-previews/profile-metrics-controller@3.1.3-preview-dff83af4c
@metamask-previews/profile-sync-controller@28.0.2-preview-dff83af4c
@metamask-previews/ramps-controller@13.1.0-preview-dff83af4c
@metamask-previews/rate-limit-controller@7.0.1-preview-dff83af4c
@metamask-previews/react-data-query@0.2.0-preview-dff83af4c
@metamask-previews/remote-feature-flag-controller@4.2.0-preview-dff83af4c
@metamask-previews/sample-controllers@4.0.4-preview-dff83af4c
@metamask-previews/seedless-onboarding-controller@9.1.0-preview-dff83af4c
@metamask-previews/selected-network-controller@26.1.0-preview-dff83af4c
@metamask-previews/shield-controller@5.1.1-preview-dff83af4c
@metamask-previews/signature-controller@39.1.2-preview-dff83af4c
@metamask-previews/social-controllers@0.1.0-preview-dff83af4c
@metamask-previews/storage-service@1.0.1-preview-dff83af4c
@metamask-previews/subscription-controller@6.1.2-preview-dff83af4c
@metamask-previews/transaction-controller@64.0.0-preview-dff83af4c
@metamask-previews/transaction-pay-controller@19.1.0-preview-dff83af4c
@metamask-previews/user-operation-controller@41.2.0-preview-dff83af4c

@abretonc7s abretonc7s added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit b8be99c Apr 10, 2026
341 checks passed
@abretonc7s abretonc7s deleted the feat/perps/sync-april-9th branch April 10, 2026 14:00
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.

3 participants