-
Notifications
You must be signed in to change notification settings - Fork 2.9k
chore(public-docsite-v9): enable build-less DX for storybook #26476
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
Merged
Hotell
merged 5 commits into
microsoft:master
from
Hotell:hotell/build/ts/path-aliases-for-all
Feb 1, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dbfb85e
feat(scripts-storybook): implement createPathAliasesConfig util for c…
Hotell 13c667a
chore(.storybook): replace babel-loader with swc in root storybook co…
Hotell a511e52
feat(scripts-storybook): add registerRules helper and replace tsConfi…
Hotell 6dee5ba
chore(scripts-storybook): move logic from monorepo root /.storybook t…
Hotell ab0f72f
chore(public-docsite-v9): enable build-less DX for storybook with swc
Hotell 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 +1,10 @@ | ||
| export { getPackageStoriesGlob, getCodesandboxBabelOptions, loadWorkspaceAddon, registerTsPaths } from './utils'; | ||
| export { | ||
| getPackageStoriesGlob, | ||
| loadWorkspaceAddon, | ||
| registerTsPaths, | ||
| registerRules, | ||
| createPathAliasesConfig, | ||
| overrideDefaultBabelLoader, | ||
| } from './utils'; | ||
|
|
||
| export * as rules from './rules'; |
This file contains hidden or 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,17 @@ | ||
| const rules = require('./rules'); | ||
| const { | ||
| createPathAliasesConfig, | ||
| getPackageStoriesGlob, | ||
| loadWorkspaceAddon, | ||
| registerRules, | ||
| registerTsPaths, | ||
| } = require('./utils'); | ||
|
|
||
| module.exports = { | ||
| ...require('./utils'), | ||
| createPathAliasesConfig, | ||
| getPackageStoriesGlob, | ||
| loadWorkspaceAddon, | ||
| registerRules, | ||
| registerTsPaths, | ||
| rules, | ||
| }; |
6 changes: 6 additions & 0 deletions
6
.storybook/custom-loader.js → ...ts/storybook/src/loaders/custom-loader.js
This file contains hidden or 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 hidden or 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,66 @@ | ||
| const { _createCodesandboxRule } = require('./utils'); | ||
|
|
||
| /** | ||
| * v8 uses SCSS/CSS modules | ||
| * @type {import("webpack").RuleSetRule} | ||
| */ | ||
| const scssRule = { | ||
| test: /\.scss$/, | ||
| enforce: 'pre', | ||
| exclude: [/node_modules/], | ||
| use: [ | ||
| { | ||
| // creates style nodes from JS strings | ||
| loader: '@microsoft/loader-load-themed-styles', | ||
| }, | ||
| { | ||
| // translates CSS into CommonJS | ||
| loader: 'css-loader', | ||
| options: { | ||
| esModule: false, | ||
| modules: true, | ||
| importLoaders: 2, | ||
| }, | ||
| }, | ||
| { | ||
| loader: 'postcss-loader', | ||
| options: { | ||
| postcssOptions: { | ||
| plugins: ['autoprefixer'], | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| loader: 'sass-loader', | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| /** | ||
| * | ||
| * @type {import("webpack").RuleSetRule} | ||
| */ | ||
| const griffelRule = { | ||
| test: /\.tsx?$/, | ||
| exclude: [/node_modules/], | ||
| enforce: 'post', | ||
| use: [ | ||
| { | ||
| loader: '@griffel/webpack-loader', | ||
| options: { | ||
| babelOptions: { | ||
| presets: ['@babel/preset-typescript'], | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| /** | ||
| * @type {import("webpack").RuleSetRule} | ||
| */ | ||
| const codesandboxRule = _createCodesandboxRule(); | ||
|
|
||
| exports.scssRule = scssRule; | ||
| exports.griffelRule = griffelRule; | ||
| exports.codesandboxRule = codesandboxRule; |
This file contains hidden or 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,36 @@ | ||
| import { getAllPackageInfo } from '@fluentui/scripts-monorepo'; | ||
| import * as semver from 'semver'; | ||
|
|
||
| import { codesandboxRule } from './rules'; | ||
|
|
||
| describe(`rules`, () => { | ||
| describe(`codesandbox`, () => { | ||
| it(`should generate rule definition with overridden babel loader`, () => { | ||
| const unstablePackage = Object.values(getAllPackageInfo()).find(metadata => { | ||
| return ( | ||
| metadata.packagePath.includes('packages/') && | ||
| metadata.packageJson.version.startsWith('9') && | ||
| semver.prerelease(metadata.packageJson.version) !== null | ||
| ); | ||
| }); | ||
|
|
||
| const options = (codesandboxRule.use as { options: Record<string, unknown> }).options; | ||
| expect(options).toEqual( | ||
| expect.objectContaining({ | ||
| customize: expect.stringContaining('loaders/custom-loader.js'), | ||
| plugins: [ | ||
| [ | ||
| expect.any(Function), | ||
| expect.objectContaining({ | ||
| '@fluentui/react-utilities': { replace: '@fluentui/react-components' }, | ||
| ...(unstablePackage | ||
| ? { [unstablePackage.packageJson.name]: { replace: '@fluentui/react-components/unstable' } } | ||
| : null), | ||
| }), | ||
| ], | ||
| ], | ||
| }), | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.