@@ -2,24 +2,21 @@ import fs from 'fs';
22import { dirname , join } from 'path' ;
33import * as process from 'process' ;
44import VirtualModulesPlugin from 'webpack-virtual-modules' ;
5- import { container , Configuration } from 'webpack' ;
5+ import { container , type Configuration } from 'webpack' ;
66import { logger } from '@storybook/node-logger' ;
7- // NOTE: @storybook /core-common is deprecated while still available, considering importing
8- // from 'storybook/internal/common' or '@storybook/core'. Considering requires Storybook 8
9- // at least and change this in the next breaking change version.
10- import { normalizeStories } from '@storybook/core-common' ;
11- import { ModuleFederationPluginOptions } from '@module-federation/utilities' ;
12-
13- import { ModuleFederationConfig } from '@nx/webpack' ;
7+ import { normalizeStories } from '@storybook/core/common' ;
148import withModuleFederation from '../utils/with-module-federation' ;
159import { correctImportPath } from '../utils/correctImportPath' ;
1610
11+ import type { moduleFederationPlugin } from '@module-federation/sdk' ;
12+ import type { ModuleFederationConfig } from '@nx/webpack' ;
13+
1714const { ModuleFederationPlugin } = container ;
1815
1916export type Preset = string | { name : string } ;
2017
2118type Options = {
22- moduleFederationConfig ?: ModuleFederationPluginOptions ;
19+ moduleFederationConfig ?: moduleFederationPlugin . ModuleFederationPluginOptions ;
2320 nxModuleFederationConfig ?: ModuleFederationConfig ;
2421 presets : {
2522 apply < T > ( preset : Preset ) : Promise < T > ;
@@ -70,17 +67,16 @@ export const webpack = async (
7067 ) ;
7168
7269 const index = plugins . findIndex (
73- //@ts -ignore
74- ( plugin ) => plugin . constructor . name === 'VirtualModulesPlugin' ,
70+ ( plugin ) => plugin ?. constructor . name === 'VirtualModulesPlugin' ,
7571 ) ;
7672
7773 if ( index !== - 1 ) {
7874 logger . info ( `=> [MF] Detected plugin VirtualModulesPlugin` ) ;
7975
80- /* eslint-disable @typescript-eslint/no-explicit-any */
81- const plugin = plugins [ index ] as any ;
76+ const plugin = plugins [ index ] as VirtualModulesPlugin ;
8277
83- const virtualEntries = plugin . _staticModules ; // TODO: Exist another way to get virtual modules? Or maybe it's good idea to open a PR adding a method to get modules?
78+ const virtualEntries : Record < string , string > =
79+ plugin . getModuleList ( 'static' ) ;
8480 const virtualEntriesPaths : string [ ] = Object . keys ( virtualEntries ) ;
8581
8682 logger . info ( `=> [MF] Write files from VirtualModulesPlugin` ) ;
0 commit comments