Skip to content

Commit

Permalink
chore: re export preset path for rsbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
nyqykk committed Nov 1, 2024
1 parent d1e0f3e commit 7e1daef
Show file tree
Hide file tree
Showing 10 changed files with 396 additions and 636 deletions.
4 changes: 4 additions & 0 deletions .changeset/hungry-ghosts-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
'@module-federation/storybook-addon': patch
---
chore: re export preset path for rsbuild
2 changes: 1 addition & 1 deletion apps/rslib-module/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const config: StorybookConfig = {
},
addons: [
{
name: '@module-federation/storybook-addon/preset.js',
name: '@module-federation/storybook-addon/preset',
options: {
remotes: {
'rslib-module':
Expand Down
10 changes: 9 additions & 1 deletion apps/rslib-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ nx serve rslib-module

Dev package

1.

```
nx serve rslib-module
```

2.

```
nx serve rslib-module & nx storybook rslib-module
nx storybook rslib-module
```

visit http://localhost:6006
2 changes: 1 addition & 1 deletion packages/storybook-addon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const config: StorybookConfig = {
},
addons: [
{
name: '@module-federation/storybook-addon/preset.js',
name: '@module-federation/storybook-addon/preset',
options: {
// add remote here and then you can load remote in your story
remotes: {
Expand Down
16 changes: 13 additions & 3 deletions packages/storybook-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
"README.md"
],
"author": "Fiodorov Andrei <[email protected]> (https://github.com/fyodorovandrei)",
"main": "dist/src/index.js",
"module": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"exports": {
".": {
"import": "./dist/src/index.js",
"require": "./dist/src/index.js",
"types": "./dist/src/indexd.ts"
"types": "./dist/src/index.d.ts"
},
"./preset": {
"import": "./dist/preset.js",
"require": "./dist/preset.js",
"types": "./dist/preset.d.ts"
},
"./*": "./*"
},
Expand All @@ -33,9 +41,11 @@
]
}
},
"devDependencies": {
"dependencies": {
"@module-federation/enhanced": "workspace:*",
"@module-federation/sdk": "workspace:*",
"@module-federation/sdk": "workspace:*"
},
"devDependencies": {
"@module-federation/utilities": "workspace:*",
"@rsbuild/core": "^1.0.19",
"@storybook/core-common": "7.6.20",
Expand Down
16 changes: 0 additions & 16 deletions packages/storybook-addon/preset.js

This file was deleted.

20 changes: 20 additions & 0 deletions packages/storybook-addon/preset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { withModuleFederation } from './src/utils/with-module-federation-enhanced-rsbuild';

import type { RsbuildConfig } from '@rsbuild/core';
import type { moduleFederationPlugin } from '@module-federation/sdk';

export default {
rsbuildFinal: (
config: RsbuildConfig,
options: moduleFederationPlugin.ModuleFederationPluginOptions,
) => {
const { remotes, shared, name, shareStrategy } = options;

return withModuleFederation(config, {
name,
remotes,
shared,
shareStrategy,
});
},
};
5 changes: 1 addition & 4 deletions packages/storybook-addon/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
"outputPath": "packages/storybook-addon/dist",
"main": "packages/storybook-addon/src/index.ts",
"tsConfig": "packages/storybook-addon/tsconfig.lib.json",
"assets": [
"packages/storybook-addon/*.md",
"packages/storybook-addon/preset.js"
]
"assets": ["packages/storybook-addon/*.md"]
},
"dependsOn": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook-addon/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts", "preset.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
Loading

0 comments on commit 7e1daef

Please sign in to comment.