Skip to content

Commit 9033735

Browse files
build(sb): 👷 update sb build to vite & remove babel build (#332)
2 parents 2393208 + 20442e0 commit 9033735

File tree

12 files changed

+577
-391
lines changed

12 files changed

+577
-391
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ jobs:
2727
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
2828
with:
2929
path: node_modules
30-
key: modules-${{ hashFiles('yarn-lock.json') }}
30+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-yarn-
3133
3234
- name: Install Dependencies
3335
if: steps.cache-node-modules.outputs.cache-hit != 'true'
@@ -52,7 +54,9 @@ jobs:
5254
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
5355
with:
5456
path: node_modules
55-
key: modules-${{ hashFiles('yarn-lock.json') }}
57+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
58+
restore-keys: |
59+
${{ runner.os }}-yarn-
5660
5761
- name: Install Dependencies
5862
if: steps.cache-node-modules.outputs.cache-hit != 'true'
@@ -80,7 +84,9 @@ jobs:
8084
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
8185
with:
8286
path: node_modules
83-
key: modules-${{ hashFiles('yarn-lock.json') }}
87+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
88+
restore-keys: |
89+
${{ runner.os }}-yarn-
8490
8591
- name: Install Dependencies
8692
if: steps.cache-node-modules.outputs.cache-hit != 'true'
@@ -112,7 +118,9 @@ jobs:
112118
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
113119
with:
114120
path: node_modules
115-
key: modules-${{ hashFiles('yarn-lock.json') }}
121+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
122+
restore-keys: |
123+
${{ runner.os }}-yarn-
116124
117125
- name: Install Dependencies
118126
if: steps.cache-node-modules.outputs.cache-hit != 'true'

.storybook/main.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
const { mergeConfig } = require("vite");
2+
13
const config = {
24
framework: "@storybook/react",
3-
core: { builder: "webpack5" },
5+
core: { builder: "@storybook/builder-vite" },
6+
async viteFinal(config: any, options: any) {
7+
return mergeConfig(config, {
8+
// customize the Vite config here
9+
build: {
10+
minify: false,
11+
sourcemap: false,
12+
},
13+
});
14+
},
15+
416
// storyStoreV7 removes the circular dependency issue with Webpack 5
517
// So, we added ThemeProvider in preview.jsx and so src/theme should work for HMR
6-
features: { storyStoreV7: true, babelModeV7: true },
18+
// features: { storyStoreV7: true, babelModeV7: true },
719
stories: ["../src/*/stories/*.stories.@(ts|tsx)"],
820
addons: [
9-
"storybook-addon-preview",
21+
// "storybook-addon-preview",
1022
"@storybook/addon-essentials",
1123
"@storybook/addon-a11y",
1224
{

.storybook/preview-head.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
crossorigin="anonymous"
55
href="https://rsms.me/inter/inter.css"
66
/>
7+
8+
<!-- For Builder Vite issue with Jest Mock -->
9+
<script>
10+
window.global = window;
11+
</script>

.swcrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"env": { "coreJs": 3 },
2+
"env": { "coreJs": 3.22 },
33
"exclude": [
44
"fileMock.js$",
55
"styleMock.js$",
6-
".test.tsx$",
7-
".test-d.ts$",
86
".component.tsx$",
97
".stories.tsx$",
108
"Jsx.ts$",
@@ -29,5 +27,6 @@
2927
}
3028
}
3129
},
32-
"sourceMaps": true
30+
"sourceMaps": true,
31+
"minify": true
3332
}

.swcrc.build

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"env": {
3+
"coreJs": 3
4+
},
5+
"exclude": [
6+
"fileMock.js$",
7+
"styleMock.js$",
8+
".test-d.ts$",
9+
".test.tsx$",
10+
".component.tsx$",
11+
".stories.tsx$",
12+
"Jsx.ts$",
13+
"Tsx.ts$"
14+
],
15+
"jsc": {
16+
"loose": true,
17+
"parser": {
18+
"syntax": "typescript",
19+
"tsx": true,
20+
"decorators": false,
21+
"dynamicImport": false
22+
},
23+
"transform": {
24+
"react": {
25+
"runtime": "automatic",
26+
"pragma": "React.createElement",
27+
"pragmaFrag": "React.Fragment",
28+
"throwIfNamespace": true,
29+
"development": false,
30+
"useBuiltins": false
31+
}
32+
}
33+
},
34+
"sourceMaps": true,
35+
"minify": true
36+
}

babel.config.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

jest.config.ts renamed to jest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { join } = require("path");
66
const pkg = require("./package.json");
77

88
// eslint-disable-next-line import/no-anonymous-default-export
9-
export default {
9+
module.exports = {
1010
rootDir: __dirname,
1111
displayName: pkg.name,
1212
testEnvironment: "jsdom",
@@ -20,4 +20,7 @@ export default {
2020
},
2121
coveragePathIgnorePatterns: ["node_modules", "__mocks__", "stories"],
2222
clearMocks: true,
23+
transform: {
24+
"^.+\\.(t|j)sx?$": ["@swc/jest"],
25+
},
2326
};

package.json

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,18 @@
4343
"boot": "yarn previews",
4444
"previews": "node scripts/create-previews.js",
4545
"storybook": "yarn previews && start-storybook -p 6006",
46-
"test": "jest --config ./jest.config.ts --no-cache",
46+
"test": "jest --config ./jest.config.js --no-cache",
4747
"lint": "eslint --color --ext .js,.jsx,.ts,.tsx .",
4848
"lint:fix": "eslint --color --ext .js,.jsx,.ts,.tsx . --fix",
4949
"format": "prettier --check \"./**/*.{html,css,js,jsx,ts,tsx,md,json}\"",
5050
"format:fix": "prettier --write --list-different --cache \"./**/*.{html,css,js,jsx,ts,tsx,md,json}\"",
5151
"format:package": "sort-package-json package.json",
5252
"build": "yarn swc",
53-
"prebabel": "rimraf dist",
54-
"babel": "yarn babel:cjs && yarn babel:esm",
55-
"postbabel": "yarn babel:types",
56-
"babel:cjs": "cross-env BABEL_ENV=cjs babel src --extensions .ts,.tsx -d dist/cjs --source-maps",
57-
"babel:esm": "cross-env BABEL_ENV=esm babel src --extensions .ts,.tsx -d dist/esm --source-maps",
58-
"babel:types": "tsc --emitDeclarationOnly --project tsconfig.prod.json --declarationDir dist/types",
5953
"preswc": "rimraf out",
6054
"swc": "yarn swc:cjs && yarn swc:esm",
6155
"postswc": "yarn swc:types",
62-
"swc:cjs": "swc src -d out/cjs -C module.type=commonjs",
63-
"swc:esm": "swc src -d out/esm -C module.type=es6",
56+
"swc:cjs": "swc src -d out/cjs -C module.type=commonjs --config-file .swcrc.build",
57+
"swc:esm": "swc src -d out/esm -C module.type=es6 --config-file .swcrc.build",
6458
"swc:types": "tsc --emitDeclarationOnly --project tsconfig.prod.json --declarationDir out/types",
6559
"storybook-build": "yarn previews && build-storybook",
6660
"prepublishOnly": "pinst --disable",
@@ -103,14 +97,6 @@
10397
"tailwind-merge": "^1.3.0"
10498
},
10599
"devDependencies": {
106-
"@babel/cli": "7.18.6",
107-
"@babel/core": "7.18.6",
108-
"@babel/plugin-proposal-class-properties": "7.18.6",
109-
"@babel/plugin-proposal-private-methods": "7.18.6",
110-
"@babel/plugin-proposal-private-property-in-object": "7.18.6",
111-
"@babel/preset-env": "7.18.6",
112-
"@babel/preset-react": "7.18.6",
113-
"@babel/preset-typescript": "7.18.6",
114100
"@commitlint/cli": "17.0.3",
115101
"@commitlint/config-conventional": "17.0.3",
116102
"@release-it/conventional-changelog": "5.0.0",
@@ -119,8 +105,7 @@
119105
"@storybook/addon-actions": "6.5.9",
120106
"@storybook/addon-essentials": "6.5.9",
121107
"@storybook/addon-postcss": "2.0.0",
122-
"@storybook/builder-webpack5": "6.5.9",
123-
"@storybook/manager-webpack5": "6.5.9",
108+
"@storybook/builder-vite": "^0.1.38",
124109
"@storybook/react": "6.5.9",
125110
"@swc/cli": "0.1.57",
126111
"@swc/core": "1.2.207",
@@ -139,9 +124,7 @@
139124
"all-contributors-cli": "6.20.0",
140125
"autoprefixer": "10.4.7",
141126
"axe-core": "4.4.2",
142-
"babel-jest": "28.1.1",
143-
"babel-loader": "8.2.5",
144-
"babel-plugin-jsx-remove-data-test-id": "3.0.0",
127+
"@swc/jest": "0.2.21",
145128
"browserlist": "1.0.1",
146129
"chalk": "4.1.2",
147130
"concurrently": "7.2.2",
@@ -180,10 +163,8 @@
180163
"sort-package-json": "1.57.0",
181164
"storybook-addon-preview": "2.2.0",
182165
"tailwindcss": "3.1.4",
183-
"ts-node": "10.8.1",
184-
"tslib": "2.4.0",
185166
"typescript": "4.7.4",
186-
"webpack": "5.73.0"
167+
"vite": "^2.9.13"
187168
},
188169
"peerDependencies": {
189170
"react": "16.x || 17.x || 18.x",

src/badge/stories/BadgeBasic.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ export const Outline: Story = {
8080

8181
export const Prefix: Story = {
8282
...Default,
83-
args: { prefix: <SlotIcon /> },
83+
args: { ...Default.args, prefix: <SlotIcon /> },
8484
};

src/badge/stories/BadgeStack.stories.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentMeta, ComponentStoryObj } from "@storybook/react";
22

3-
import { createPreviewTabs } from "../../../.storybook/utils";
3+
import { createControls, createPreviewTabs } from "../../../.storybook/utils";
44

55
import js from "./templates/BadgeStackJsx";
66
import ts from "./templates/BadgeStackTsx";
@@ -12,6 +12,9 @@ type Story = ComponentStoryObj<typeof BadgeStack>;
1212
export default {
1313
title: "Primitives/Badge/Stack",
1414
component: BadgeStack,
15+
argTypes: createControls("badge", {
16+
ignore: ["wrapElement", "as", "ref", "prefix"],
17+
}),
1518
parameters: {
1619
layout: "centered",
1720
options: { showPanel: false },

0 commit comments

Comments
 (0)