@metamask-previews/perps-controller 1.2.0-preview-152e02d → 1.2.0-preview-e0f8f1907

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - Exclude `@myx-trade/sdk` from build output by default, reducing bundled size by ~57% ([#8234](https://github.com/MetaMask/core/pull/8234))
13
+ - MYX provider files are stripped from `dist/` unless `MM_PERPS_MYX_PROVIDER_ENABLED=true` is set at build time
14
+ - Static import of `MYXProvider` replaced with dynamic `import()` to break the eager dependency chain
15
+
10
16
  ## [1.2.0]
11
17
 
12
18
  ### Added
@@ -24,7 +24,6 @@ const perpsConfig_1 = require("./constants/perpsConfig.cjs");
24
24
  const perpsErrorCodes_1 = require("./perpsErrorCodes.cjs");
25
25
  const AggregatedPerpsProvider_1 = require("./providers/AggregatedPerpsProvider.cjs");
26
26
  const HyperLiquidProvider_1 = require("./providers/HyperLiquidProvider.cjs");
27
- const MYXProvider_1 = require("./providers/MYXProvider.cjs");
28
27
  const AccountService_1 = require("./services/AccountService.cjs");
29
28
  const DataLakeService_1 = require("./services/DataLakeService.cjs");
30
29
  const DepositService_1 = require("./services/DepositService.cjs");
@@ -2836,17 +2835,27 @@ async function _PerpsController_performInitialization() {
2836
2835
  messenger: this.messenger,
2837
2836
  });
2838
2837
  this.providers.set('hyperliquid', hyperLiquidProvider);
2839
- // Register MYX provider if enabled via feature flag
2838
+ // Register MYX provider if enabled via feature flag.
2839
+ // Uses dynamic import so @myx-trade/sdk is excluded from the bundle
2840
+ // unless MM_PERPS_MYX_PROVIDER_ENABLED=true is set at build time.
2841
+ // Wrapped in try/catch so a missing module (stripped at build time)
2842
+ // only skips MYX registration instead of aborting initialization.
2840
2843
  const isMYXEnabled = __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_isMYXProviderEnabled).call(this);
2841
2844
  if (isMYXEnabled) {
2842
- const myxProvider = new MYXProvider_1.MYXProvider({
2843
- isTestnet: perpsConfig_1.PROVIDER_CONFIG.MYX_TESTNET_ONLY || this.state.isTestnet,
2844
- platformDependencies: __classPrivateFieldGet(this, _PerpsController_options, "f").infrastructure,
2845
- });
2846
- this.providers.set('myx', myxProvider);
2847
- __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_debugLog).call(this, 'PerpsController: MYX provider registered', {
2848
- isTestnet: perpsConfig_1.PROVIDER_CONFIG.MYX_TESTNET_ONLY || this.state.isTestnet,
2849
- });
2845
+ try {
2846
+ const { MYXProvider } = await import("./providers/MYXProvider.cjs");
2847
+ const myxProvider = new MYXProvider({
2848
+ isTestnet: perpsConfig_1.PROVIDER_CONFIG.MYX_TESTNET_ONLY || this.state.isTestnet,
2849
+ platformDependencies: __classPrivateFieldGet(this, _PerpsController_options, "f").infrastructure,
2850
+ });
2851
+ this.providers.set('myx', myxProvider);
2852
+ __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_debugLog).call(this, 'PerpsController: MYX provider registered', {
2853
+ isTestnet: perpsConfig_1.PROVIDER_CONFIG.MYX_TESTNET_ONLY || this.state.isTestnet,
2854
+ });
2855
+ }
2856
+ catch {
2857
+ __classPrivateFieldGet(this, _PerpsController_instances, "m", _PerpsController_debugLog).call(this, 'PerpsController: MYX provider module not available (stripped from build), skipping registration');
2858
+ }
2850
2859
  }
2851
2860
  // Set up active provider based on activeProvider value in state
2852
2861
  // 'aggregated' is treated as just another provider that wraps others