Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add storybook addon that supports Module Federation remote containers #598

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
321c3c5
feat: add package storybook-plugin
fyodorovandrei Feb 23, 2023
d985b19
feat(storybook-plugin): add test for webpack fn
fyodorovandrei Feb 23, 2023
996dcbd
Merge branch 'main' of github.com:fyodorovandrei/universe into featur…
fyodorovandrei Feb 23, 2023
df70cd1
feat: add package storybook-plugin
fyodorovandrei Feb 23, 2023
87c8eb4
feat(storybook-plugin): add test for webpack fn
fyodorovandrei Feb 23, 2023
08db8ba
feat(storybook-plugin): remove storybook config overwrite
fyodorovandrei Feb 24, 2023
975a687
Merge branch 'features/add-storybook-plugin' of github.com:fyodorovan…
fyodorovandrei Feb 24, 2023
ad5491f
Merge branch 'main' into features/add-storybook-plugin
ScriptedAlchemy Feb 28, 2023
777f55e
feat(storybook-plugin): replace VirtualModulePlugin from storybook we…
fyodorovandrei Mar 1, 2023
44f4454
Merge branch 'features/add-storybook-plugin' of github.com:fyodorovan…
fyodorovandrei Mar 1, 2023
39d2dac
Merge branch 'main' into features/add-storybook-plugin
fyodorovandrei Mar 1, 2023
971df96
fix(storybook-plugin): update todo comment
fyodorovandrei Mar 1, 2023
0e756ee
fix(storybook-plugin): remove preview file
fyodorovandrei Mar 1, 2023
165438b
feat(storybook-plugin): move utils in own folder
fyodorovandrei Mar 1, 2023
a5cda56
feat(storybook-plugin): update logic to replace or push the plugin Vi…
fyodorovandrei Mar 1, 2023
1dbaba8
Merge branch 'main' into features/add-storybook-plugin
fyodorovandrei Mar 1, 2023
c358b69
feat(storybook-plugin): fix package description
fyodorovandrei Mar 1, 2023
607ec12
feat(storybook-plugin): update README.md
fyodorovandrei Mar 1, 2023
6114788
feat(storybook-addon): rename from plugin to addon
fyodorovandrei Mar 3, 2023
47d500e
chore: add package storybook-addon in release action
fyodorovandrei Mar 3, 2023
1c9801f
fix(storybook-addon): update package repository url
fyodorovandrei Mar 3, 2023
b9622be
fix(storybook-addon): update mock and add virtual module plugin after…
fyodorovandrei Mar 3, 2023
ea91d12
feat(storybook-addon): add tests for correctImportPath util
fyodorovandrei Mar 3, 2023
56f70eb
feat(storybook-addon): refactor webpack fn
fyodorovandrei Mar 3, 2023
6f49d3d
feat(storybook-addon): write all webpack virtual modules in node_modu…
fyodorovandrei Mar 8, 2023
0cbdeef
fix(storybook-addon): update test
fyodorovandrei Mar 8, 2023
56eea82
Merge remote-tracking branch 'upstream/main' into features/add-storyb…
fyodorovandrei Mar 8, 2023
6ff0df1
fix(storybook-addon): rollback yarn.lock
fyodorovandrei Mar 8, 2023
6b04005
feature(storybook-addon): write files recursive when move from virtua…
fyodorovandrei Mar 9, 2023
6722d96
feat(storybook-addon): move util `correctImportPath` in common utils …
fyodorovandrei Mar 10, 2023
73738d4
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Mar 14, 2023
431b9fd
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Mar 21, 2023
b90772e
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Mar 23, 2023
99b9dbd
feat(storybook-addon): add 2 mf apps and add support for nx mf config
fyodorovandrei Apr 11, 2023
97abbb5
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Apr 11, 2023
f9e35fe
fix(storybook-addon): pass webpack config
fyodorovandrei Apr 11, 2023
2d8c67f
fix(storybook-addon): rollback util call
fyodorovandrei Apr 11, 2023
e593cfb
feat(storybook-addon): implement custom utils `withModuleFederation` …
fyodorovandrei Apr 19, 2023
ac04456
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Apr 19, 2023
797fcd9
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Apr 19, 2023
9d53bcc
feat(storybook-addon): update package versions
fyodorovandrei Apr 20, 2023
a953cb3
feat(storybook-addon): update README.md
fyodorovandrei Apr 21, 2023
9927f06
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Apr 22, 2023
fb1570b
Merge branch 'main' of https://github.com/module-federation/universe …
fyodorovandrei Apr 23, 2023
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
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- all
- nextjs-mf
- node
- storybook-addon
- typescript
- utils
- native-federation-typescript
Expand Down Expand Up @@ -46,7 +47,7 @@ jobs:
- name: Build
shell: bash
run: |
yarn nx run-many --target=build --projects=typescript,utils,node,nextjs-mf,native-federation-typescript,native-federation-tests
yarn nx run-many --target=build --projects=typescript,utils,node,nextjs-mf,storybook-addon,native-federation-typescript,native-federation-tests
- name: Version
shell: bash
run: |
Expand Down
11 changes: 11 additions & 0 deletions apps/reactRemoteUI/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
18 changes: 18 additions & 0 deletions apps/reactRemoteUI/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
11 changes: 11 additions & 0 deletions apps/reactRemoteUI/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'reactRemoteUI',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/reactRemoteUI',
};
6 changes: 6 additions & 0 deletions apps/reactRemoteUI/module-federation.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
name: 'reactRemoteUI',
exposes: {
'./Button': './src/Button',
},
};
8 changes: 8 additions & 0 deletions apps/reactRemoteUI/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "react-remote-ui",
"version": "1.0.0",
"devDependencies": {
"@module-federation/storybook-addon": "0.0.1",
"@module-federation/utilities": "1.6.1"
}
}
107 changes: 107 additions & 0 deletions apps/reactRemoteUI/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"name": "reactRemoteUI",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/reactRemoteUI/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/webpack:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"compiler": "babel",
"outputPath": "dist/apps/reactRemoteUI",
"index": "apps/reactRemoteUI/src/index.html",
"baseHref": "/",
"main": "apps/reactRemoteUI/src/main.ts",
"tsConfig": "apps/reactRemoteUI/tsconfig.app.json",
"assets": [
"apps/reactRemoteUI/src/favicon.ico"
],
"styles": ["apps/reactRemoteUI/src/styles.scss"],
"scripts": [],
"isolatedConfig": true,
"webpackConfig": "apps/reactRemoteUI/webpack.config.js"
},
"configurations": {
"development": {
"extractLicenses": false,
"optimization": false,
"sourceMap": true,
"vendorChunk": true
},
"production": {
"fileReplacements": [
{
"replace": "apps/reactRemoteUI/src/environments/environment.ts",
"with": "apps/reactRemoteUI/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"webpackConfig": "apps/reactRemoteUI/webpack.config.prod.js"
}
}
},
"serve": {
"executor": "@nrwl/react:module-federation-dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "reactRemoteUI:build",
"hmr": true,
"port": 4201
},
"configurations": {
"development": {
"buildTarget": "reactRemoteUI:build:development"
},
"production": {
"buildTarget": "reactRemoteUI:build:production",
"hmr": false
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/reactRemoteUI/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/reactRemoteUI/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"serve-static": {
"executor": "@nrwl/web:file-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "reactRemoteUI:build",
"port": 4201
},
"configurations": {
"development": {
"buildTarget": "reactRemoteUI:build:development"
},
"production": {
"buildTarget": "reactRemoteUI:build:production"
}
}
}
},
"tags": []
}
78 changes: 78 additions & 0 deletions apps/reactRemoteUI/src/Button/Button.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
:root {
--color-white: white;
--primary-color: #0075E1;
--primary-color-light: #e6f2fd;
--secondary-color: #8C8C8C;
--secondary-color-light: #DADADA;
}

.button {
padding: 12px;
border-radius: 4px;
outline: none;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 8px;
white-space: nowrap;
background-image: none;
background-color: transparent;
border: 1px solid transparent;
cursor: pointer;
transition: all .2s cubic-bezier(.645,.045,.355,1);
user-select: none;
touch-action: manipulation;
font-size: 16px;
line-height: 1.5;
}

.button:disabled {
cursor: not-allowed;
}

.primary {
border-color: var(--primary-color);
background-color: var(--primary-color);
color: var(--color-white);
}

.primary .icon {
fill: var(--color-white);
}

.primary:disabled {
border-color: var(--secondary-color);
background-color: var(--secondary-color);
color: var(--secondary-color-light);
}

.primary:disabled .icon {
fill: var(--secondary-color-light);
}

.secondary {
border-color: var(--primary-color);
background-color: var(--color-white);
color: var(--primary-color);
}

.secondary .icon {
fill: var(--primary-color);
}

.secondary:hover {
border-color: var(--primary-color);
background-color: var(--primary-color-light);
color: var(--primary-color);
}

.secondary:disabled {
border-color: var(--secondary-color);
background-color: var(--color-white);
color: var(--secondary-color);
}

.secondary:disabled .icon {
fill: var(--secondary-color);
}
26 changes: 26 additions & 0 deletions apps/reactRemoteUI/src/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { HTMLProps } from 'react';
import classNames from 'classnames';

import styles from './Button.module.css';

type ButtonProps = {
type?: 'button' | 'submit' | 'reset' | undefined;
variant?: 'primary' | 'secondary';
} & HTMLProps<HTMLButtonElement>;

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ children, className, variant = 'primary', ...props }, ref) => {
const cssClasses = classNames(styles.button, {
[styles.primary]: variant === 'primary',
[styles.secondary]: variant === 'secondary',
});

return (
<button {...props} ref={ref} className={`${cssClasses} ${className}`}>
{children}
</button>
);
}
);

export default Button;
1 change: 1 addition & 0 deletions apps/reactRemoteUI/src/Button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Button';
16 changes: 16 additions & 0 deletions apps/reactRemoteUI/src/bootstrap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';

import Button from './Button';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<StrictMode>
<div>
UI Library Button:
<Button>Test Button</Button>
</div>
</StrictMode>
);
3 changes: 3 additions & 0 deletions apps/reactRemoteUI/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true,
};
6 changes: 6 additions & 0 deletions apps/reactRemoteUI/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file can be replaced during build by using the `fileReplacements` array.
// When building for production, this file is replaced with `environment.prod.ts`.

export const environment = {
production: false,
};
Binary file added apps/reactRemoteUI/src/favicon.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions apps/reactRemoteUI/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>ReactRemoteUi</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<div id="root"></div>
</body>
</html>
1 change: 1 addition & 0 deletions apps/reactRemoteUI/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import('./bootstrap');
1 change: 1 addition & 0 deletions apps/reactRemoteUI/src/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */
23 changes: 23 additions & 0 deletions apps/reactRemoteUI/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../node_modules/@nrwl/react/typings/image.d.ts"
],
"exclude": [
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
20 changes: 20 additions & 0 deletions apps/reactRemoteUI/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json"
}
Loading