-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Hotell
merged 2 commits into
microsoft:master
from
Hotell:hotell/build-system/migrate-react-storybook-to-new-dx-1
Jul 21, 2021
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const rootMain = require('../../../.storybook/main'); | ||
|
||
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; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 )
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see previous comment
I'd say this statement is a bit exaggerated (can you provide specific data metrics ) ?
quite contrary. with nx and generators everything is automated and kept in sync ✌️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's a better approach to not have extra junk by default, then only add it if/when needed.
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.
Do we actually need declaration rollup for non-component packages?
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.
There was a problem hiding this comment.
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.