Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
0ff7697
feat(storybook-addon): use new api to get the virtual static modules
fyodorovandrei Dec 1, 2024
d7f83db
fix(storybook-addon): import types `ModuleFederationPluginOptions` fr…
fyodorovandrei Dec 3, 2024
672bca9
fix(storybook-addon): rollback `pnpm-lock.yaml` file
fyodorovandrei Dec 3, 2024
1b6cce2
feat(storybook-addon): update `pnpm-lock.yaml` file
fyodorovandrei Dec 3, 2024
a363c17
Merge branch 'main' of https://github.com/module-federation/core into…
fyodorovandrei Dec 4, 2024
7a4c802
Merge branch 'main' into upgrade-package-deps-to-allow-to-use-new-api
fyodorovandrei Dec 8, 2024
1e819dd
Merge branch 'main' into fork/fyodorovandrei/upgrade-package-deps-to-…
ScriptedAlchemy Dec 12, 2024
13a9c7b
Merge branch 'main' into fork/fyodorovandrei/upgrade-package-deps-to-…
ScriptedAlchemy Dec 12, 2024
b8f9b0c
Merge branch 'main' into fork/fyodorovandrei/upgrade-package-deps-to-…
ScriptedAlchemy Dec 12, 2024
0114756
chore: locks
ScriptedAlchemy Dec 12, 2024
a78e151
Merge branch 'main' into upgrade-package-deps-to-allow-to-use-new-api
fyodorovandrei Dec 13, 2024
5433d08
Merge branch 'main' into upgrade-package-deps-to-allow-to-use-new-api
fyodorovandrei Dec 18, 2024
da16f28
Merge branch 'main' of https://github.com/module-federation/core into…
fyodorovandrei Dec 21, 2024
f93a590
Merge remote-tracking branch 'origin/upgrade-package-deps-to-allow-to…
fyodorovandrei Dec 21, 2024
c1129b5
feat(storybook-addon): update `pnpm-lock.yaml` file
fyodorovandrei Dec 21, 2024
0c7481d
Merge branch 'main' of https://github.com/module-federation/core into…
fyodorovandrei Dec 30, 2024
0197c22
Merge branch 'main' into fork/fyodorovandrei/upgrade-package-deps-to-…
ScriptedAlchemy Jan 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tame-taxis-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/storybook-addon': major
---

Use new api to get the virtual static modules
2 changes: 1 addition & 1 deletion packages/storybook-addon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = storybookConfig;

### Rsbuild App or Rslib Module

```
```js
import { dirname, join } from 'node:path';
import type { StorybookConfig } from 'storybook-react-rsbuild';

Expand Down
2 changes: 2 additions & 0 deletions packages/storybook-addon/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ export default {
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/storybook-addon',
// https://mswjs.io/docs/migrations/1.x-to-2.x#requestresponsetextencoder-is-not-defined-jest
testEnvironment: 'jest-fixed-jsdom',
};
16 changes: 9 additions & 7 deletions packages/storybook-addon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@module-federation/storybook-addon",
"version": "3.0.18",
"version": "3.1.0",
"description": "Storybook addon to consume remote module federated apps/components",
"type": "commonjs",
"license": "MIT",
Expand Down Expand Up @@ -53,28 +53,30 @@
"@module-federation/sdk": "workspace:*"
},
"devDependencies": {
"jest-fixed-jsdom": "^0.0.9",
"@module-federation/utilities": "workspace:*",
"@rsbuild/core": "^1.0.19",
"@storybook/core-common": "7.6.20",
"@storybook/node-logger": "7.6.20",
"@storybook/core": "^8.4.6",
"webpack": "5.93.0",
"webpack-virtual-modules": "0.6.2"
},
"peerDependencies": {
"@rsbuild/core": "^1.0.1",
"@module-federation/utilities": "^3.1.38",
"@module-federation/sdk": "^0.8.0",
"@nx/react": ">= 16.0.0",
"@nx/webpack": ">= 16.0.0",
"@storybook/core-common": "^6.5.16 || ^7.0.0 || ^ 8.0.0",
"@storybook/node-logger": "^6.5.16 || ^7.0.0 || ^ 8.0.0",
"@storybook/core": ">= 8.2.0",
"@storybook/node-logger": "^6.5.16 || ^7.0.0 || ^8.0.0",
"webpack": "^5.75.0",
"webpack-virtual-modules": "^0.5.0 || ^0.6.0"
"webpack-virtual-modules": "0.6.2"
},
"peerDependenciesMeta": {
"@rsbuild/core": {
"optional": true
},
"@module-federation/utilities": {
"@module-federation/sdk": {
"optional": true
},
"@nx/react": {
Expand All @@ -83,7 +85,7 @@
"@nx/webpack": {
"optional": true
},
"@storybook/core-common": {
"@storybook/core": {
"optional": true
},
"@storybook/node-logger": {
Expand Down
24 changes: 10 additions & 14 deletions packages/storybook-addon/src/lib/storybook-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ import fs from 'fs';
import { dirname, join } from 'path';
import * as process from 'process';
import VirtualModulesPlugin from 'webpack-virtual-modules';
import { container, Configuration } from 'webpack';
import { container, type Configuration } from 'webpack';
import { logger } from '@storybook/node-logger';
// NOTE: @storybook/core-common is deprecated while still available, considering importing
// from 'storybook/internal/common' or '@storybook/core'. Considering requires Storybook 8
// at least and change this in the next breaking change version.
import { normalizeStories } from '@storybook/core-common';
import { ModuleFederationPluginOptions } from '@module-federation/utilities';

import { ModuleFederationConfig } from '@nx/webpack';
import { normalizeStories } from '@storybook/core/common';
import withModuleFederation from '../utils/with-module-federation';
import { correctImportPath } from '../utils/correctImportPath';

import type { moduleFederationPlugin } from '@module-federation/sdk';
import type { ModuleFederationConfig } from '@nx/webpack';

const { ModuleFederationPlugin } = container;

export type Preset = string | { name: string };

type Options = {
moduleFederationConfig?: ModuleFederationPluginOptions;
moduleFederationConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
nxModuleFederationConfig?: ModuleFederationConfig;
presets: {
apply<T>(preset: Preset): Promise<T>;
Expand Down Expand Up @@ -70,17 +67,16 @@ export const webpack = async (
);

const index = plugins.findIndex(
//@ts-ignore
(plugin) => plugin.constructor.name === 'VirtualModulesPlugin',
(plugin) => plugin?.constructor.name === 'VirtualModulesPlugin',
);

if (index !== -1) {
logger.info(`=> [MF] Detected plugin VirtualModulesPlugin`);

/* eslint-disable @typescript-eslint/no-explicit-any */
const plugin = plugins[index] as any;
const plugin = plugins[index] as VirtualModulesPlugin;

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?
const virtualEntries: Record<string, string> =
plugin.getModuleList('static');
const virtualEntriesPaths: string[] = Object.keys(virtualEntries);

logger.info(`=> [MF] Write files from VirtualModulesPlugin`);
Expand Down
46 changes: 42 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.