Skip to content

Commit

Permalink
Migrate storybook to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonrobot committed Jan 26, 2024
1 parent af29b85 commit 60ae8d3
Show file tree
Hide file tree
Showing 26 changed files with 2,246 additions and 1,498 deletions.
33 changes: 25 additions & 8 deletions .storybook/main.js → .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import type { StorybookConfig } from "@storybook/react-webpack5";

/* globals __dirname:false */
const path = require("path");
const glob = require("glob");
const ROOT = path.resolve(__dirname, "..");
const PKGS = path.resolve(ROOT, "packages");
const STORIES = path.resolve(ROOT, "stories");

const wrapForPnp = (packageName) => path.dirname(require.resolve(path.join(packageName, 'package.json')));
const wrapForPnp = (packageName) =>
path.dirname(require.resolve(path.join(packageName, "package.json")));

module.exports = {
const config: StorybookConfig = {
webpackFinal: async (config) => {
// Read all the victory packages and alias.
glob
.sync(path.join(PKGS, "victory*/package.json"))
.forEach((pkgPath) => {
const key = path.dirname(path.relative(PKGS, pkgPath));
glob.sync(path.join(PKGS, "victory*/package.json")).forEach((pkgPath) => {
const key = path.dirname(path.relative(PKGS, pkgPath));
if (config?.resolve?.alias) {
config.resolve.alias[key] = path.resolve(path.dirname(pkgPath));
});
}
});

return config;
},

addons: [
"@storybook/addon-options/register",
"@storybook/addon-essentials",
{
name: "@storybook/addon-storysource",
options: {
Expand Down Expand Up @@ -49,4 +52,18 @@ module.exports = {
},
},
},

typescript: {
// typescript compilation check is disabled until we upgrade the babel version
// which is required for the latest version of storybook to do typechecking
// https://github.com/FormidableLabs/victory/issues/2746
check: false,
checkOptions: {
typescript: {
configFile: path.join(__dirname, "../tsconfig.base.json"),
},
},
},
};

export default config;
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "^7.17.12",
"@changesets/cli": "^2.24.1",
"@storybook/addon-actions": "^7.6.7",
"@storybook/addon-options": "^5.3.21",
"@storybook/addon-storysource": "^7.6.7",
"@storybook/addon-storysource": "^7.6.10",
"@storybook/addon-essentials": "^7.6.10",
"@storybook/react": "^7.6.7",
"@storybook/react-webpack5": "^7.6.7",
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
Expand Down
Loading

0 comments on commit 60ae8d3

Please sign in to comment.