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

chore(react-storybook): migrate to new DX stage 1 #19037

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ packages/react-focus/ @microsoft/cxe-red @khmakoto
packages/react-image/ @microsoft/cxe-prg
packages/react-text/ @microsoft/cxe-prg
packages/react-input/ @microsoft/cxe-red @ecraig12345
packages/react-storybook/ @microsoft/cxe-prg @ling1726 @layershifter
packages/storybook/ @microsoft/cxe-prg @ling1726 @layershifter
packages/react-storybook/ @microsoft/cxe-prg @microsoft/teams-prg
packages/storybook/ @microsoft/cxe-prg @microsoft/teams-prg
packages/react-link/ @microsoft/cxe-red @khmakoto
packages/react-slider/ @microsoft/cxe-red
packages/react-tabs/ @microsoft/cxe-red @behowell
Expand Down
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@fluentui/react-positioning": { "tags": ["vNext"], "implicitDependencies": [] },
"@fluentui/react-provider": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] },
"@fluentui/react-shared-contexts": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] },
"@fluentui/react-storybook": { "implicitDependencies": [] },
"@fluentui/react-storybook": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] },
"@fluentui/react-tabs": { "implicitDependencies": [] },
"@fluentui/react-tabster": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] },
"@fluentui/react-text": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] },
Expand Down
11 changes: 11 additions & 0 deletions packages/react-storybook/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const rootMain = require('../../../.storybook/main');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this package ever have stories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe in future (to have stories that can be e2e tested)? . it will need a bit overhaul -> migrating from knobs to controls etc

not a big deal - just generator at work ( we can remove it as needed via automation later )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package really doesn't need either storybook config or API Extractor. Adding these files to new packages where they aren't needed is just increasing the maintenance burden later (and in the case of API Extractor configs, unnecessarily increasing build time).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really doesn't need either storybook config

please see previous comment

and in the case of API Extractor configs, unnecessarily increasing build time

I'd say this statement is a bit exaggerated (can you provide specific data metrics ) ?

  • all new DX packages should be unified as much as possible for a sake of easier automation. API extractor is a must for typescript declaration rolluping. It is to be determined if it's gonna be used also for documentation generation purposes or not.

is just increasing the maintenance burden

quite contrary. with nx and generators everything is automated and kept in sync ✌️

Copy link
Member

@ecraig12345 ecraig12345 Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really doesn't need either storybook config

please see previous comment

IMO it's a better approach to not have extra junk by default, then only add it if/when needed.

and in the case of API Extractor configs, unnecessarily increasing build time

I'd say this statement is a bit exaggerated (can you provide specific data metrics ) ?

If an API Extractor config is present, the API Extractor generation step runs. Go look for how long that takes in the build. It's probably not huge but cumulatively it is adding a bit of time.

  • all new DX packages should be unified as much as possible for a sake of easier automation. API extractor is a must for typescript declaration rolluping. It is to be determined if it's gonna be used also for documentation generation purposes or not.

Do we actually need declaration rollup for non-component packages?

is just increasing the maintenance burden

quite contrary. with nx and generators everything is automated and kept in sync ✌️

Generators can't magically know which projects should and should not have an API Extractor config. And in general, the existence of generators shouldn't excuse doing things that are otherwise silly/unnecessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search build logs for finished 'api-extractor' in -- it takes at least a few seconds (more for some packages) because it has to build a TS program for each package, plus however long the analysis takes. The only straightforward way to marginally improve that is not using API Extractor where it's not needed. The more comprehensive but less straightforward way (which we may need to investigate at some point if we keep using the tool and want to invest in improving build perf) is creating a shared TS program object and programmatically invoking any tool that needs to use it, instead of using their CLIs.


module.exports = /** @type {Pick<import('../../../.storybook/main').StorybookConfig,'addons'|'stories'|'webpackFinal'>} */ ({
stories: [...rootMain.stories, '../src/**/*.stories.mdx', '../src/**/*.stories.@(ts|tsx)'],
addons: [...rootMain.addons],
webpackFinal: (config, options) => {
const localConfig = { ...rootMain.webpackFinal(config, options) };

return localConfig;
},
});
7 changes: 7 additions & 0 deletions packages/react-storybook/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as rootPreview from '../../../.storybook/preview';

/** @type {typeof rootPreview.decorators} */
export const decorators = [...rootPreview.decorators];

/** @type {typeof rootPreview.parameters} */
export const parameters = { ...rootPreview.parameters };
9 changes: 9 additions & 0 deletions packages/react-storybook/.storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true
},
"exclude": ["../**/*.test.ts", "../**/*.test.js", "../**/*.test.tsx", "../**/*.test.jsx"],
"include": ["../src/**/*", "*.js"]
}
1 change: 1 addition & 0 deletions packages/react-storybook/config/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "@fluentui/scripts/api-extractor/api-extractor.common.json"
}
5 changes: 5 additions & 0 deletions packages/react-storybook/config/api-extractor.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "./api-extractor.json",
"mainEntryPointFilePath": "<projectFolder>/dist/<unscopedPackageName>/src/index.d.ts"
}
7 changes: 4 additions & 3 deletions packages/react-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
"code-style": "just-scripts code-style",
"just": "just-scripts",
"lint": "just-scripts lint",
"start": "just-scripts dev:storybook",
"start-test": "echo \"This is DEPRECATED instead use 'test --watch'\" && just-scripts jest-watch",
"start": "yarn storybook",
"test": "jest",
"update-snapshots": "echo \"This is DEPRECATED instead use 'test -u'\" && just-scripts jest -u"
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-storybook/src && yarn docs",
"storybook": "start-storybook"
},
"devDependencies": {
"@fluentui/eslint-plugin": "^1.3.2",
Expand Down
9 changes: 5 additions & 4 deletions packages/react-storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"target": "es5",
"target": "ES5",
"module": "CommonJS",
"lib": ["ES2015", "dom"],
"outDir": "dist",
"jsx": "react",
"declaration": true,
"experimentalDecorators": true,
"importHelpers": true,
"noUnusedLocals": true,
"preserveConstEnums": true,
"types": ["jest", "custom-global", "inline-style-expand-shorthand"]
},
"include": ["src"]
"types": ["jest", "custom-global", "inline-style-expand-shorthand", "storybook__addons"]
}
}
6 changes: 5 additions & 1 deletion workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@
"projectType": "library",
"sourceRoot": "packages/react-shared-contexts/src"
},
"@fluentui/react-storybook": { "root": "packages/react-storybook", "projectType": "library" },
"@fluentui/react-storybook": {
"root": "packages/react-storybook",
"projectType": "library",
"sourceRoot": "packages/react-storybook/src"
},
"@fluentui/react-tabs": { "root": "packages/react-tabs", "projectType": "library" },
"@fluentui/react-tabster": {
"root": "packages/react-tabster",
Expand Down