Skip to content

Commit 187c2ef

Browse files
committed
build: update build so that themes declarations are exported
This replaces rollup-plugin-dts with the more traditional @rollup/plugin-typescript, as well as move some types around so themes can be exported as a standalone with its own TypeScript config. It also restores importing React and the ESLint rule react/react-in-jsx-scope to preserve React 16 compatibility.
1 parent 5abcb3e commit 187c2ef

File tree

132 files changed

+337
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+337
-232
lines changed

.codesandbox/ci.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"installCommand": "install:codesandbox",
32
"buildCommand": "build:prod",
4-
"sandboxes": ["react95-template-xkfj0"]
3+
"node": "16",
4+
"sandboxes": [
5+
"react95-template-xkfj0"
6+
]
57
}

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ module.exports = {
4343
'react/jsx-props-no-spreading': 'off',
4444
'react/no-array-index-key': 'off',
4545
'react/prop-types': 'off',
46-
'react/react-in-jsx-scope': 'off',
4746
'react/require-default-props': 'off',
4847
'react/static-property-placement': ['error', 'static public field']
4948
},

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"lint": "eslint --ext .js,.ts,.tsx src",
4646
"lint:fix": "yarn run lint --fix",
4747
"semantic-release": "semantic-release",
48-
"install:codesandbox": "yarn --ignore-engines",
4948
"cz": "git-cz"
5049
},
5150
"peerDependencies": {
@@ -61,6 +60,7 @@
6160
"@babel/plugin-transform-runtime": "^7.18.9",
6261
"@babel/preset-env": "^7.18.9",
6362
"@babel/preset-react": "^7.18.6",
63+
"@rollup/plugin-typescript": "^8.3.4",
6464
"@storybook/addon-docs": "^6.5.9",
6565
"@storybook/addon-storysource": "^6.5.9",
6666
"@storybook/react": "^6.5.9",
@@ -103,7 +103,6 @@
103103
"rollup-plugin-babel": "^4.4.0",
104104
"rollup-plugin-commonjs": "^9.3.4",
105105
"rollup-plugin-copy": "^3.4.0",
106-
"rollup-plugin-dts": "^4.2.2",
107106
"rollup-plugin-esbuild": "^4.9.1",
108107
"rollup-plugin-node-resolve": "^4.2.4",
109108
"rollup-plugin-replace": "^2.2.0",

rollup.config.js

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
11
import esbuild from 'rollup-plugin-esbuild';
22
import copy from 'rollup-plugin-copy';
3-
import dts from 'rollup-plugin-dts';
3+
import typescript from '@rollup/plugin-typescript';
44
import replace from 'rollup-plugin-replace';
55
import packageJson from './package.json';
66

77
const NODE_ENV = process.env.NODE_ENV || 'development';
88

9-
const bundle = config => [
10-
{
11-
...config,
12-
external: id => !/^[./]/.test(id),
13-
plugins: [
14-
...config.plugins,
15-
replace({
16-
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
17-
}),
18-
esbuild({ loaders: { '.js': 'jsx' } })
19-
]
20-
},
21-
{
22-
...config,
23-
output: config.output.dir
24-
? config.output
25-
: {
26-
file: packageJson.types,
27-
format: 'es'
28-
},
29-
external: id => !/^[./]/.test(id),
30-
plugins: [
31-
...config.plugins,
32-
replace({
33-
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
34-
}),
35-
dts()
36-
]
37-
}
38-
];
9+
const baseBundle = {
10+
external: id => !/^[./]/.test(id),
11+
plugins: [
12+
replace({
13+
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
14+
}),
15+
esbuild()
16+
]
17+
};
3918

4019
export default [
41-
...bundle({
20+
{
21+
...baseBundle,
4222
input: './src/index.ts',
4323
output: [
4424
{
@@ -52,23 +32,39 @@ export default [
5232
sourcemap: true
5333
}
5434
],
55-
plugins: []
56-
}),
57-
...bundle({
35+
plugins: [
36+
...baseBundle.plugins,
37+
typescript({
38+
tsconfig: './tsconfig.build.index.json',
39+
declaration: true,
40+
declarationDir: 'dist'
41+
})
42+
]
43+
},
44+
{
45+
...baseBundle,
5846
input: './src/common/themes/index.ts',
5947
output: {
6048
dir: 'dist/themes',
6149
exports: 'default',
62-
format: 'cjs'
50+
format: 'cjs',
51+
preserveModules: true,
52+
preserveModulesRoot: 'src/common/themes',
53+
sourcemap: true
6354
},
64-
preserveModules: true,
6555
plugins: [
56+
...baseBundle.plugins,
6657
copy({
6758
targets: [
6859
{ src: './src/assets/fonts/dist/*', dest: './dist/fonts' },
6960
{ src: './src/assets/images/*', dest: './dist/images' }
7061
]
62+
}),
63+
typescript({
64+
tsconfig: './tsconfig.build.themes.json',
65+
declaration: true,
66+
declarationDir: 'dist/themes'
7167
})
7268
]
73-
})
69+
}
7470
];

src/Anchor/Anchor.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { render } from '@testing-library/react';
24

35
import { Anchor } from './Anchor';

src/Anchor/Anchor.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import styled from 'styled-components';
34

45
import { Anchor } from './Anchor';

src/AppBar/AppBar.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { render } from '@testing-library/react';
2+
import React from 'react';
23

34
import { AppBar } from './AppBar';
45

src/AppBar/AppBar.stories.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import React from 'react';
2-
import styled from 'styled-components';
1+
import { ComponentMeta } from '@storybook/react';
2+
import React, { useState } from 'react';
33
import {
44
AppBar,
5-
Toolbar,
6-
TextField,
75
Button,
6+
Divider,
87
List,
98
ListItem,
10-
Divider
9+
TextField,
10+
Toolbar
1111
} from 'react95';
12-
import { ComponentMeta } from '@storybook/react';
12+
import styled from 'styled-components';
1313
import logoIMG from '../assets/images/logo.png';
1414

1515
const Wrapper = styled.div`
@@ -24,7 +24,7 @@ export default {
2424
} as ComponentMeta<typeof AppBar>;
2525

2626
export function Default() {
27-
const [open, setOpen] = React.useState(false);
27+
const [open, setOpen] = useState(false);
2828

2929
return (
3030
<AppBar>

src/Avatar/Avatar.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { render } from '@testing-library/react';
2+
import React from 'react';
23

34
import { renderWithTheme, theme } from '../../test/utils';
45

src/Avatar/Avatar.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import { Avatar } from 'react95';
34
import styled from 'styled-components';
45

src/Bar/Bar.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { renderWithTheme } from '../../test/utils';
24

35
import { Bar } from './Bar';

src/Bar/Bar.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import { AppBar, Bar, Button, Toolbar } from 'react95';
34
import styled from 'styled-components';
45

src/Button/Button.spec.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { render, fireEvent } from '@testing-library/react';
1+
import { fireEvent, render } from '@testing-library/react';
2+
import React from 'react';
23

34
import { renderWithTheme, theme } from '../../test/utils';
45
import { blockSizes } from '../common/system';

src/Button/Button.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2-
import { useState } from 'react';
2+
import React, { useState } from 'react';
33
import {
44
Button,
55
Cutout,

src/Checkbox/Checkbox.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { renderWithTheme } from '../../test/utils';
24
import { Checkbox } from './Checkbox';
35

src/ColorInput/ColorInput.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { fireEvent } from '@testing-library/react';
2+
import React from 'react';
23
import { renderWithTheme } from '../../test/utils';
34
import { ColorInput } from './ColorInput';
45

src/ColorInput/ColorInput.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import styled from 'styled-components';
34

45
import { ColorInput, Cutout } from 'react95';

src/Counter/Counter.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { renderWithTheme } from '../../test/utils';
34

45
import { Counter } from './Counter';

src/Counter/Counter.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2-
import { useState } from 'react';
2+
import React, { useState } from 'react';
33
import { Button, Counter, Panel } from 'react95';
44
import styled from 'styled-components';
55

src/Cutout/Cutout.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { render } from '@testing-library/react';
2+
import React from 'react';
23

34
import { Cutout } from './Cutout';
45

src/Cutout/Cutout.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import { Cutout, Window, WindowContent } from 'react95';
34
import styled from 'styled-components';
45

src/DatePicker/DatePicker.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable camelcase, react/jsx-pascal-case */
22
import { ComponentMeta } from '@storybook/react';
3+
import React from 'react';
34
import { DatePicker__UNSTABLE } from 'react95';
45
import styled from 'styled-components';
56

src/DatePicker/DatePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef, useCallback, useMemo, useState } from 'react';
1+
import React, { forwardRef, useCallback, useMemo, useState } from 'react';
22
import styled from 'styled-components';
33

44
import { Button } from '../Button/Button';

src/Desktop/Desktop.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { renderWithTheme } from '../../test/utils';
34

45
import { Desktop } from './Desktop';

src/Desktop/Desktop.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import styled from 'styled-components';
2-
3-
import { Desktop } from 'react95';
41
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
3+
import { Desktop } from 'react95';
4+
import styled from 'styled-components';
55

66
const Wrapper = styled.div`
77
padding: 5rem;

src/Divider/Divider.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { renderWithTheme } from '../../test/utils';
24

35
import { Divider } from './Divider';

src/Divider/Divider.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import styled from 'styled-components';
34

45
import { Divider, List, ListItem } from 'react95';

src/Fieldset/Fieldset.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { renderWithTheme, theme } from '../../test/utils';
24

35
import { Fieldset } from './Fieldset';

src/Fieldset/Fieldset.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2-
import { useState } from 'react';
2+
import React, { useState } from 'react';
33
import { Checkbox, Cutout, Fieldset, Window, WindowContent } from 'react95';
44
import styled from 'styled-components';
55

src/Hourglass/Hourglass.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import styled from 'styled-components';
2-
3-
import { Hourglass } from 'react95';
41
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
3+
import { Hourglass } from 'react95';
4+
import styled from 'styled-components';
55

66
const Wrapper = styled.div`
77
padding: 5rem;

src/Hourglass/Hourglass.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef } from 'react';
1+
import React, { forwardRef } from 'react';
22
import styled from 'styled-components';
33
import { getSize } from '../common/utils';
44
import base64hourglass from './base64hourglass';

src/List/List.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { renderWithTheme } from '../../test/utils';
24

35
import { List } from './List';

src/List/List.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import styled from 'styled-components';
34

4-
import { List, ListItem, Bar, Divider } from 'react95';
5+
import { Bar, Divider, List, ListItem } from 'react95';
56

67
const Wrapper = styled.div`
78
padding: 5rem;

src/ListItem/ListItem.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { renderWithTheme, theme } from '../../test/utils';
24
import { blockSizes } from '../common/system';
35
import { ListItem } from './ListItem';

src/LoadingIndicator/LoadingIndicator.spec.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import { renderWithTheme } from '../../test/utils';
24
import { LoadingIndicator } from './LoadingIndicator';
35

src/LoadingIndicator/LoadingIndicator.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import styled from 'styled-components';
34

45
import { LoadingIndicator } from 'react95';

src/NumberField/NumberField.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { fireEvent } from '@testing-library/react';
2+
import React from 'react';
23

34
import { renderWithTheme } from '../../test/utils';
45
import { NumberField } from './NumberField';

src/NumberField/NumberField.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentMeta } from '@storybook/react';
2+
import React from 'react';
23
import { Cutout, NumberField } from 'react95';
34
import styled from 'styled-components';
45

src/Panel/Panel.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { render } from '@testing-library/react';
2+
import React from 'react';
23

34
import { Panel } from './Panel';
45

0 commit comments

Comments
 (0)