Skip to content

Commit 4c0b9df

Browse files
committed
build: replace building with vite
BREAKING CHANGE: This commit contains possibly several braking changes. It updates large number of dependencies and adds `exports` field in the package.json. We also slightly change the setting of the tsconfig. Ref UXD-1107
1 parent 331b201 commit 4c0b9df

24 files changed

+1246
-445
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ module.exports = {
128128
unnamedComponents: 'arrow-function',
129129
},
130130
],
131+
'react/react-in-jsx-scope': 'off',
131132
'fp/no-arguments': 'error',
132133
'fp/no-delete': 'error',
133134
'fp/no-get-set': 'error',

.github/workflows/CD.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
41
name: CD
52

63
on:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ yarn-error.log
1212
stats
1313
coverage
1414
.scannerwork
15+
tsconfig.tsbuildinfo
1516

1617
.yarn/*
1718
!.yarn/patches

.storybook/main.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const { includes } = require('ramda');
1+
import { includes } from 'ramda';
2+
import type { StorybookConfig } from '@storybook/react/types';
23

3-
module.exports = {
4+
const config: StorybookConfig = {
45
stories: ['../src/**/*.stories.@(tsx|jsx|mdx)'],
56
addons: [
67
'@storybook/addon-a11y',
@@ -48,3 +49,5 @@ module.exports = {
4849
return config;
4950
},
5051
};
52+
53+
export default config;

.storybook/tsconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "..",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"target": "ES2017"
6+
}
7+
}

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"sonarlint.connectedMode.project": {
77
"connectionId": "https://sonarqube.prod-eks.ssc.band",
88
"projectKey": "securityscorecard_design-system_3c8a3f7f-942f-4414-a39a-f4b4f20c2f3f"
9-
}
9+
},
10+
"typescript.tsdk": "node_modules/typescript/lib"
1011
}

.yarnrc.yml

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
nodeLinker: node-modules
22

33
packageExtensions:
4-
"@babel/plugin-transform-react-jsx@*":
4+
'@babel/plugin-transform-react-jsx@*':
55
dependencies:
6-
"@babel/core": ^7.18.9
7-
"@babel/preset-env@*":
6+
'@babel/core': ^7.18.9
7+
'@babel/preset-env@*':
88
dependencies:
99
"@babel/core": ^7.0.0-0
1010
"@babel/plugin-syntax-jsx@*":
@@ -13,23 +13,29 @@ packageExtensions:
1313
"@figspec/react@*":
1414
dependencies:
1515
react: ^16.14.0
16-
"@phenomnomnominal/tsquery@*":
16+
'@phenomnomnominal/tsquery@*':
1717
dependencies:
1818
typescript: 4.7.4
19-
"@storybook/addon-docs@*":
19+
'@storybook/addon-docs@*':
2020
dependencies:
2121
"@babel/core": ^7.18.9
2222
webpack: ^5.75.0
23-
"@storybook/core-common@*":
23+
'@storybook/core-common@*':
2424
dependencies:
2525
react: ^16.14.0
2626
react-dom: ^16.14.0
27-
"@storybook/docs-tools@*":
27+
'@storybook/docs-tools@*':
2828
dependencies:
2929
react: ^16.14.0
3030
react-dom: ^16.14.0
31+
'@storybook/react@*':
32+
dependencies:
33+
require-from-string: ^2.0.2
3134
ts-node@*:
3235
dependencies:
33-
"@types/node": "*"
36+
'@types/node': '*'
37+
'@stylelint/postcss-css-in-js@*':
38+
dependencies:
39+
postcss-syntax: ^0.36.2
3440

3541
yarnPath: .yarn/releases/yarn-3.6.4.cjs

jest.config.js jest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
roots: ['./src'],
33
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
44
moduleFileExtensions: ['js', 'ts', 'tsx', 'json'],

package.json

+30-19
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
"description": "Security Scorecard Design System",
55
"author": "Radek Podrazky <[email protected]>",
66
"license": "Apache-2.0",
7-
"main": "build/index.js",
8-
"module": "build/index.es.js",
7+
"main": "build/index.cjs",
8+
"module": "build/index.mjs",
99
"types": "build/index.d.ts",
10+
"exports": {
11+
".": {
12+
"types": "./build/index.d.ts",
13+
"import": "./build/index.mjs",
14+
"require": "./build/index.cjs",
15+
"default": "./src/index.ts"
16+
}
17+
},
1018
"files": [
1119
"CHANGELOG.md",
1220
"LICENSE",
@@ -15,15 +23,15 @@
1523
"build"
1624
],
1725
"scripts": {
18-
"build": "rollup -c",
19-
"storybook": "start-storybook -p 8008",
20-
"storybook:build": "build-storybook --quiet",
26+
"build": "vite build",
27+
"storybook": "cross-env TS_NODE_PROJECT=.storybook/tsconfig.json start-storybook -p 8008",
28+
"storybook:build": "cross-env TS_NODE_PROJECT=.storybook/tsconfig.json build-storybook --quiet",
2129
"test:storybook:visual": "./visual-regressions/bin/take-and-check-in-docker.sh",
2230
"test:storybook:visual:update": "./visual-regressions/bin/take-and-update-in-docker.sh",
2331
"test:storybook:visual:ci": "./visual-regressions/bin/take-and-check-in-docker-ci.sh",
24-
"test": "jest -w 1",
32+
"test": "jest -w 4",
2533
"test:watch": "jest --watch",
26-
"types": "tsc --noEmit",
34+
"types": "tsc",
2735
"lint": "eslint 'src/**/*.{js,ts,tsx}'",
2836
"lint:fix": "eslint 'src/**/*.{js,ts,tsx}' --fix",
2937
"lint:css": "stylelint 'src/**/*.{js,ts,tsx}'",
@@ -88,9 +96,7 @@
8896
"@fontsource/inter": "^4.5.15",
8997
"@geometricpanda/storybook-addon-badges": "^0.2.1",
9098
"@mdx-js/react": "^1.6.22",
91-
"@rollup/plugin-commonjs": "^21.0.3",
92-
"@rollup/plugin-node-resolve": "^13.2.0",
93-
"@rollup/plugin-url": "^6.1.0",
99+
"@prisma-capacity/babel-plugin-react-display-name": "^1.0.6",
94100
"@semantic-release/changelog": "^6.0.1",
95101
"@semantic-release/commit-analyzer": "^9.0.2",
96102
"@semantic-release/git": "^10.0.1",
@@ -115,14 +121,20 @@
115121
"@testing-library/react-hooks": "^7.0.2",
116122
"@testing-library/user-event": "^13.5.0",
117123
"@types/jest": "^27.4.1",
118-
"@types/node": "^16.11.27",
124+
"@types/node": "*",
119125
"@types/react": "^18.2.0",
126+
"@types/react-dom": "^18.2.0",
127+
"@types/react-router-dom": "^5.3.3",
120128
"@types/react-select": "^4.0.18",
121-
"@types/react-table": "^7.7.10",
129+
"@types/react-table": "7.7.14",
130+
"@types/rollup-plugin-auto-external": "^2.0.5",
122131
"@types/styled-components": "^5.1.24",
123132
"@types/testing-library__jest-dom": "^5.14.3",
124133
"@typescript-eslint/eslint-plugin": "^5.16.0",
125134
"@typescript-eslint/parser": "^5.16.0",
135+
"@vitejs/plugin-react": "^4.2.1",
136+
"babel-plugin-styled-components": "^2.0.7",
137+
"cross-env": "^7.0.3",
126138
"eslint": "^8.11.0",
127139
"eslint-config-airbnb": "^19.0.4",
128140
"eslint-config-prettier": "^8.5.0",
@@ -154,13 +166,8 @@
154166
"react-select": "^4.3.1",
155167
"react-select-event": "^5.3.0",
156168
"react-test-renderer": "^16.13.1",
157-
"require-from-string": "^2.0.2",
158-
"rollup": "^2.70.1",
159169
"rollup-plugin-auto-external": "^2.0.0",
160-
"rollup-plugin-peer-deps-external": "^2.2.2",
161-
"rollup-plugin-terser": "^7.0.2",
162-
"rollup-plugin-typescript2": "^0.31.2",
163-
"rollup-plugin-visualizer": "^5.6.0",
170+
"rollup-plugin-visualizer": "^5.12.0",
164171
"semantic-release": "^19.0.2",
165172
"semantic-release-export-data": "^1.0.1",
166173
"storybook-addon-designs": "^6.2.1",
@@ -172,10 +179,14 @@
172179
"stylelint-config-styled-components": "^0.1.1",
173180
"stylelint-processor-styled-components": "^1.10.0",
174181
"ts-jest": "^27.1.4",
182+
"ts-node": "^10.9.0",
175183
"ts-react-display-name": "^1.2.2",
176184
"tslib": "^2.3.1",
177185
"typescript": "4.7.4",
178-
"typescript-plugin-styled-components": "^2.0.0"
186+
"typescript-plugin-styled-components": "^2.0.0",
187+
"vite": "^5.2.8",
188+
"vite-plugin-dts": "^3.8.1",
189+
"vite-require": "^0.2.3"
179190
},
180191
"resolutions": {
181192
"trim": "1.0.1",

rollup.config.js

-84
This file was deleted.

src/components/Breadcrumbs/Breadcrumbs.tsx

+13-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import styled from 'styled-components';
55
import { isNilOrEmpty, isNotNilOrEmpty } from 'ramda-adjunct';
66
import cls from 'classnames';
77

8-
import { BreadcrumbsProps } from './Breadcrumbs.types';
8+
import type {
9+
BreadcrumbItemProps,
10+
BreadcrumbsProps,
11+
} from './Breadcrumbs.types';
912
import { SSCIconNames } from '../../theme/icons/icons.enums';
1013
import { Icon } from '../Icon';
1114
import { DropdownMenu } from '../_internal/BaseDropdownMenu';
@@ -98,12 +101,15 @@ const Breadcrumbs = ({ children, className, ...props }: BreadcrumbsProps) => {
98101
return null;
99102
}
100103

101-
return React.cloneElement(breadcrumbItem, {
102-
isSelected:
103-
isNilOrEmpty(breadcrumbItem.props.to) &&
104-
isNilOrEmpty(breadcrumbItem.props.href),
105-
...props,
106-
});
104+
return React.cloneElement(
105+
breadcrumbItem as React.ReactElement<BreadcrumbItemProps>,
106+
{
107+
isSelected:
108+
isNilOrEmpty(breadcrumbItem.props.to) &&
109+
isNilOrEmpty(breadcrumbItem.props.href),
110+
...props,
111+
},
112+
);
107113
});
108114

109115
const allDropdownActions = slice(

src/components/Datatable/Datatable.stories.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,10 @@ export const ServerSidePlayground: Story<DatatableProps<Data>> = (args) => {
121121
const timeoutRef = useRef(null);
122122

123123
const dispatchFetchData = useCallback(
124-
({ pageSize, pageIndex, sortBy, filters, query }) => {
124+
({ pageSize, pageIndex }) => {
125125
action('onDataFetch')({
126126
pageSize,
127127
pageIndex,
128-
sortBy,
129-
filters,
130-
query,
131128
});
132129
setIsLoading(true);
133130
timeoutRef.current = setTimeout(() => {

src/components/Datatable/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { default as Datatable } from './Datatable';
22
export * from './Datatable.types';
3-
export { CustomColumnOptions } from './Table/Table.types';
3+
export type { CustomColumnOptions } from './Table/Table.types';

src/components/DatatableV2/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { default as DatatableV2 } from './Datatable';
2-
export { DatatableColumnDef, DatatableOptions } from './Datatable.types';
2+
export type { DatatableColumnDef, DatatableOptions } from './Datatable.types';

src/components/HintTooltip/HintTooltip.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default {
2929
const Popup = (
3030
<Stack gap="md">
3131
<Paragraph size="md">This is the tooltip content</Paragraph>
32-
<Link variant="text">Here is some link</Link>
32+
<Link>Here is some link</Link>
3333
</Stack>
3434
);
3535

src/components/Tabs/Tabs.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import { equals } from 'ramda';
44

55
import { Inline } from '../layout';
6-
import { TabsProps } from './Tabs.types';
6+
import { TabProps, TabsProps } from './Tabs.types';
77
import { TabVariants } from './Tabs.enums';
88
import { SpaceSizes } from '../../theme/space.enums';
99
import { BaseTabsWrapper } from '../_internal/BaseTabs/BaseTabsWrapper';
@@ -41,8 +41,8 @@ const Tabs = ({
4141
return null;
4242
}
4343

44-
return React.cloneElement(tab, {
45-
__key: tab.props.value,
44+
return React.cloneElement<Partial<TabProps>>(tab, {
45+
key: tab.props.value,
4646
__variant: variant,
4747
__isExpanded: isExpanded,
4848
__isSelected: selectedPatternMatcher(tab.props.value, selectedValue),

0 commit comments

Comments
 (0)