Skip to content

Commit

Permalink
chore: Merge support into master
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbsmith committed May 23, 2023
2 parents b91a644 + 2e7522f commit 59b827a
Show file tree
Hide file tree
Showing 369 changed files with 8,788 additions and 4,565 deletions.
138 changes: 65 additions & 73 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const createCompiler = require('@storybook/addon-docs/mdx-compiler-plugin');
const modulesPath = path.resolve(__dirname, '../modules');
const getSpecifications = require('../modules/docs/utils/get-specifications');

const processDocs = process.env.SKIP_DOCGEN !== 'true';

module.exports = {
stories: [
'../modules/docs/mdx/**/*.mdx',
Expand All @@ -27,56 +29,60 @@ module.exports = {
},
webpackFinal: async config => {
// Get the specifications object and replace with a real object in the spec.ts file
const specs = await getSpecifications();
if (processDocs) {
const specs = await getSpecifications();

config.module.rules.push({
test: /.ts$/,
include: [path.resolve(__dirname, '../modules/docs')],
use: [
{
loader: require.resolve('string-replace-loader'),
options: {
search: '[/* SPEC_FILES_REPLACE_BY_WEBPACK */]',
replace: JSON.stringify(specs, null, ' '),
},
},
],
});

// Load the source code of story files to display in docs.
config.module.rules.push({
test: /stories.*\.tsx?$/,
include: [modulesPath],
loaders: [
{
loader: require.resolve('@storybook/source-loader'),
options: {parser: 'typescript'},
},
],
enforce: 'pre',
});

config.module.rules.push({
test: /.+\.tsx?$/,
include: [modulesPath],
exclude: /examples|stories|spec|codemod|docs/,
loaders: [
{
loader: path.resolve(__dirname, 'symbol-doc-loader'),
},
],
enforce: 'pre',
});
}

// Convert mdx links to point to github
/**
* This was added to tell webpack not to parse the typescript.js file in node_modules and suppress these warnings:
* WARN Module not found: Error: Can't resolve 'perf_hooks' in 'node_modules/typescript/lib'
* WARN resolve 'perf_hooks' in 'node_modules/typescript/lib
*
*
* These warnings relate to this open GitHub issue: https://github.com/microsoft/TypeScript/issues/39436
* If you no longer see these warnings when this is config is removed, you can safely delete this config.
*/
config.module = {
...config.module,
// This solution was taken from this comment: https://github.com/microsoft/TypeScript/issues/39436#issuecomment-817029140
noParse: [require.resolve('typescript/lib/typescript.js')],
}

config.module.rules.push({
test: /.ts$/,
include: [path.resolve(__dirname, '../modules/docs')],
use: [
{
loader: require.resolve('string-replace-loader'),
options: {
search: '[/* SPEC_FILES_REPLACE_BY_WEBPACK */]',
replace: JSON.stringify(specs, null, ' '),
},
},
],
});

/**
* Added this because Storybook 6.3 is on emotion 10, so we rewrote the imports to point to emotion 11
* https://github.com/storybookjs/storybook/issues/13145
*/
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
'@emotion/core': '@emotion/react',
'emotion-theming': '@emotion/react',
},
};
config.module.noParse = [require.resolve('typescript/lib/typescript.js')];

// Update @storybook/addon-docs webpack rules to load all .mdx files in storybook
const mdxRule = config.module.rules.find(rule => rule.test.toString() === /\.mdx$/.toString());
mdxRule.use.find(loader => loader.loader.includes('mdx1-csf')).options['compilers'] = [
createCompiler({}),
];

// Convert mdx links to point to github
config.module.rules.push({
test: /\.mdx?$/,
include: [path.resolve(__dirname, '..')],
Expand All @@ -91,19 +97,6 @@ module.exports = {
],
});

// Load the source code of story files to display in docs.
config.module.rules.push({
test: /stories.*\.tsx?$/,
include: [modulesPath],
loaders: [
{
loader: require.resolve('@storybook/source-loader'),
options: {parser: 'typescript'},
},
],
enforce: 'pre',
});

// Load the whole example code of story files to display in docs.
config.module.rules.push({
test: /examples\/.*\.tsx?$/,
Expand All @@ -116,17 +109,24 @@ module.exports = {
enforce: 'pre',
});

config.module.rules.push({
test: /.+\.tsx?$/,
include: [modulesPath],
exclude: /examples|stories|spec|codemod|docs/,
loaders: [
{
loader: path.resolve(__dirname, 'symbol-doc-loader'),
},
],
enforce: 'pre',
});
/**
* Added this because Storybook 6.3 is on emotion 10, so we rewrote the imports to point to emotion 11
* https://github.com/storybookjs/storybook/issues/13145
*/
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
'@emotion/core': '@emotion/react',
'emotion-theming': '@emotion/react',
},
};

// Update @storybook/addon-docs webpack rules to load all .mdx files in storybook
const mdxRule = config.module.rules.find(rule => rule.test.toString() === /\.mdx$/.toString());
mdxRule.use.find(loader => loader.loader.includes('mdx1-csf')).options['compilers'] = [
createCompiler({}),
];

// Load our scss files with postscss.
// Note: This is the same as @storybook/preset-scss, but with postcss added.
Expand All @@ -144,14 +144,6 @@ module.exports = {
include: modulesPath,
});

// Remove progress updates to reduce log lines in Travis
// See: https://github.com/storybookjs/storybook/issues/2029
if (process.env.TRAVIS) {
config.plugins = config.plugins.filter(
plugin => plugin.constructor.name !== 'ProgressPlugin'
);
}

return config;
},
babel: async options => ({
Expand Down
9 changes: 6 additions & 3 deletions .storybook/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const routes = {
'/assets/system-icons/': 'tokens-icon--system-icon',
'/components/buttons/action-bar/': 'components-buttons-action-bar--basic',
'/components/buttons/button/': 'components-buttons--primary',
'/components/buttons/segmented-control/': 'preview-segmented-control--basic',
'/components/containers/card/': 'components-containers-card--basic',
'/components/containers/side-panel/': 'preview-side-panel--basic',
'/components/containers/table/': 'components-containers-table--basic',
'/components/containers/table/': 'preview-table--basic',
'/components/containers/tabs/': 'components-containers-tabs--basic',
'/components/indicators/banner/': 'components-indicators-banner--basic',
'/components/indicators/loading-dots/': 'components-indicators-loading-dots--basic',
Expand All @@ -28,20 +29,20 @@ const routes = {
'/components/layout/box/': 'components-layout-box--basic',
'/components/layout/flex/': 'components-layout-flex--basic',
'/components/layout/grid/': 'components-layout-grid--basic',
'/components/layout/stack/': 'components-layout-stack--basic-stack',
'/components/navigation/breadcrumbs/': 'components-navigation-breadcrumbs--basic',
'/components/navigation/pagination/': 'components-navigation-pagination--basic',
'/components/popups/menu/': 'components-popups-menu--basic',
'/components/popups/modal/': 'components-popups-modal--basic',
'/components/popups/popup/': 'components-popups-popup--basic',
'/components/popups/toast/': 'components-popups-toast--with-popper',
'/components/popups/toast/': 'components-popups-toast--basic',
'/components/popups/tooltip/': 'components-popups-tooltip--default-story',
'/components/text/body-text/': 'components-text-body-text--basic',
'/components/text/heading/': 'components-text-heading--basic',
'/components/text/label-text/': 'components-text-label-text--basic',
'/components/text/subtext/': 'components-text-subtext--basic',
'/components/text/text/': 'components-text-text--basic',
'/components/text/title/': 'components-text-title--basic',
'/examples/layout/': 'examples-layouts--area-column-positioning',
'/getting-started/for-developers/contributing/': 'guides-contributing--page',
'/getting-started/for-developers/resources/api-pattern-guidelines/':
'guides-api-pattern-guidelines--page',
Expand All @@ -65,6 +66,8 @@ const routes = {
'/whats-new/upgrade-guides/canvas-kit-v5-upgrade-guide/': 'guides-upgrade-guides-v5-0--page',
'/whats-new/upgrade-guides/canvas-kit-v6-upgrade-guide/': 'guides-upgrade-guides-v6-0--page',
'/whats-new/upgrade-guides/canvas-kit-v7-upgrade-guide/': 'guides-upgrade-guides-v7-0--page',
'/whats-new/upgrade-guides/canvas-kit-v8-upgrade-guide/': 'guides-upgrade-guides-v8-0--page',
'/whats-new/upgrade-guides/canvas-v9-upgrade-guide/': 'guides-upgrade-guides-v9-0--page',
};

module.exports = routes;
Loading

0 comments on commit 59b827a

Please sign in to comment.