-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(swc): upgrade storybook to v8 and migrate to SWC from babel (#841)
* fix(swc): upgrade storybook to v8 and migrate to SWC from babel All @mui/material/styled imports been replace with @emotion/styled for compatibility * refactor(storybook): fix story icon and webpack configs * fix(package.json): remove all babel dependencies * fix(webpack): fix webpack configs to work with monorepo setup * fix(style-dictionary): upgrade to style-dictionary v4 * fix(emotion): add @swc/plugin-emotion to handle component selectors in styled components * refactor(rollup): refactor and improve rollup config
- Loading branch information
1 parent
73a7837
commit bcab32f
Showing
115 changed files
with
3,063 additions
and
5,329 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,58 +1,60 @@ | ||
import { dirname, join } from "path"; | ||
const path = require("path"); | ||
const toPath = (filePath) => path.join(process.cwd(), filePath); | ||
const { plugins } = require("axe-core"); | ||
|
||
module.exports = { | ||
// Storybook version 7 needs babel config | ||
babel: (config) => { | ||
return { | ||
...config, | ||
presets: [ | ||
"@babel/preset-env", | ||
"@babel/preset-typescript", | ||
[ | ||
"@babel/preset-react", | ||
{ | ||
runtime: "automatic", | ||
}, | ||
], | ||
], | ||
plugins: [], | ||
}; | ||
}, | ||
features: { | ||
buildStoriesJson: true, | ||
// (thuang): https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#emotion11-quasi-compatibility | ||
emotionAlias: false, | ||
}, | ||
stories: [ | ||
"../packages/components/src/**/*.stories.@(js|jsx|ts|tsx)", | ||
"../packages/data-viz/src/**/*.stories.@(js|jsx|ts|tsx)", | ||
], | ||
|
||
core: { | ||
disableWhatsNewNotifications: true, | ||
}, | ||
|
||
addons: [ | ||
getAbsolutePath("@storybook/addon-links"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@storybook/addon-interactions"), | ||
getAbsolutePath("@storybook/addon-a11y"), | ||
getAbsolutePath("@storybook/react"), | ||
getAbsolutePath("storybook-addon-pseudo-states"), | ||
getAbsolutePath("@geometricpanda/storybook-addon-badges"), | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
"@storybook/addon-a11y", | ||
"@storybook/react", | ||
"storybook-addon-pseudo-states", | ||
"@geometricpanda/storybook-addon-badges", | ||
"@storybook/addon-webpack5-compiler-swc", | ||
"@chromatic-com/storybook", | ||
], | ||
|
||
framework: { | ||
name: getAbsolutePath("@storybook/react-webpack5"), | ||
options: {}, | ||
name: "@storybook/react-webpack5", | ||
options: { | ||
builder: { | ||
useSWC: true, | ||
}, | ||
}, | ||
}, | ||
// (masoudmanson): The latest update of Storybook version 7 now features | ||
// a new Docs tab, in addition to the Default, Live Preview, and Test Stories. | ||
// In order to align with our project requirements, we have set the auto Docs | ||
// tab to a value of "false" as we do not currently require its functionality. | ||
docs: { | ||
autodocs: false, | ||
|
||
swc: () => ({ | ||
jsc: { | ||
/** | ||
* (masoudmanson): This is needed to enable emotion plugin for swc | ||
* for use cases like component selectors in styled components | ||
* | ||
* for example: | ||
* | ||
* const StyledChild = styled.div` color: red; `; | ||
* | ||
* const StyledParent = styled.div` ${StyledChild} { color: green; } `; | ||
*/ | ||
experimental: { | ||
plugins: [["@swc/plugin-emotion", {}]], | ||
}, | ||
transform: { | ||
react: { | ||
runtime: "automatic", | ||
}, | ||
}, | ||
}, | ||
}), | ||
|
||
typescript: { | ||
reactDocgen: "react-docgen", | ||
}, | ||
}; | ||
/** | ||
* This function is used to resolve the absolute path of a package. | ||
* It is needed in projects that use Yarn PnP or are set up within a monorepo. | ||
*/ | ||
function getAbsolutePath(value) { | ||
return dirname(require.resolve(join(value, "package.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
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
Binary file added
BIN
+7.18 MB
...v7_macos_aarch64_0.112.2/3d90119e56180f8a6d47f21a39da9a5ca2094986f8cd26a9f3daaa8fa37e147f
Binary file not shown.
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,5 @@ | ||
{ | ||
"onlyChanged": true, | ||
"projectId": "Project:616981d9028812003ade73f3", | ||
"zip": true | ||
} |
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
Oops, something went wrong.