Skip to content

Commit 613e07e

Browse files
authored
fix #137: publish type declarations, source maps and ESM file (#156)
* fix #137: publish type declarations, source maps and ESM file * Add empty carousel story
1 parent 97d5545 commit 613e07e

File tree

5 files changed

+78
-46
lines changed

5 files changed

+78
-46
lines changed

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@
44
"description": "React UI library for Tock Node chatbots",
55
"main": "build/tock-react-kit.umd.js",
66
"module": "build/tock-react-kit.esm.js",
7+
"types": "build/tock-react-kit.d.ts",
78
"author": "François Nguyen <https://github.com/phurytw>",
89
"homepage": "https://github.com/theopenconversationkit/tock-react-kit",
910
"license": "MIT",
1011
"engines": {
1112
"node": ">=20.10.0"
1213
},
14+
"files": [
15+
"build/tock-react-kit.d.ts",
16+
"build/tock-react-kit.esm.js",
17+
"build/tock-react-kit.esm.js.map",
18+
"build/tock-react-kit.umd.js"
19+
],
1320
"scripts": {
1421
"storybook": "storybook dev -p 6006",
1522
"build-storybook": "storybook build",
1623
"build": "rollup -c --environment BUILD:production",
17-
"watch-build": "rollup -w -c --environment BUILD:production",
18-
"lint": "eslint 'src/**/*.{js,ts,tsx}' --fix --quiet",
24+
"watch-build": "rollup -w -c --environment BUILD:development",
25+
"lint": "eslint 'src/**/*.{ts,tsx}' --fix --quiet",
1926
"prepare": "rollup -c --environment BUILD:production",
2027
"version": "auto-changelog -p && git add CHANGELOG.md",
2128
"test": "echo 'Tests coming soon ...'",
@@ -53,7 +60,7 @@
5360
"@storybook/testing-library": "^0.2.0",
5461
"@types/node": "^14.0.26",
5562
"@types/react-color": "^3.0.4",
56-
"@types/react-dom": "^16.9.8",
63+
"@types/react-dom": "^18.2.8",
5764
"@types/storybook__react": "^5.2.1",
5865
"@typescript-eslint/eslint-plugin": "^3.9.1",
5966
"@typescript-eslint/parser": "^3.9.1",
@@ -71,6 +78,7 @@
7178
"react-dom": "^18.2.0",
7279
"rollup": "^3.29.0",
7380
"rollup-plugin-commonjs": "^10.1.0",
81+
"rollup-plugin-dts": "^6.0.2",
7482
"rollup-plugin-node-resolve": "^5.2.0",
7583
"rollup-plugin-replace": "^2.2.0",
7684
"rollup-plugin-typescript": "^1.0.1",

rollup.config.mjs

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
11
import commonjs from 'rollup-plugin-commonjs';
2+
import dts from 'rollup-plugin-dts';
23
import resolve from 'rollup-plugin-node-resolve';
34
import replace from 'rollup-plugin-replace';
45
import typescript from 'rollup-plugin-typescript';
56

6-
export default {
7-
input: 'src/index.ts',
8-
external: ['react', 'react-dom', '@emotion/react', '@emotion/styled'],
9-
output: [
10-
{
11-
file: 'build/tock-react-kit.umd.js',
12-
format: 'umd',
13-
name: 'TockReact',
14-
globals: {
15-
react: 'React',
16-
'react-dom': 'ReactDOM',
17-
'@emotion/styled': 'emotionStyled',
18-
'@emotion/react': 'emotionReact',
7+
export default [
8+
{
9+
input: 'src/index.ts',
10+
external: ['react', 'react-dom', '@emotion/react', '@emotion/styled'],
11+
output: [
12+
{
13+
file: 'build/tock-react-kit.umd.js',
14+
format: 'umd',
15+
name: 'TockReact',
16+
globals: {
17+
react: 'React',
18+
'react-dom': 'ReactDOM',
19+
'@emotion/styled': 'emotionStyled',
20+
'@emotion/react': 'emotionReact',
21+
},
1922
},
20-
},
21-
{
22-
file: 'build/tock-react-kit.esm.js',
23-
format: 'esm',
24-
},
25-
],
26-
plugins: [
27-
resolve(),
28-
commonjs(),
29-
typescript(),
30-
replace({
31-
'process.env.NODE_ENV': JSON.stringify('production'),
32-
}),
33-
],
34-
};
23+
{
24+
file: 'build/tock-react-kit.esm.js',
25+
format: 'esm',
26+
sourcemap: true,
27+
},
28+
],
29+
plugins: [
30+
resolve(),
31+
commonjs(),
32+
typescript(),
33+
replace({
34+
'process.env.NODE_ENV': JSON.stringify('production'),
35+
}),
36+
],
37+
},
38+
{
39+
// path to your declaration files root
40+
input: 'src/index.ts',
41+
output: [{ file: 'build/tock-react-kit.d.ts', format: 'es' }],
42+
plugins: [dts()],
43+
},
44+
];

src/components/Carousel/Carousel.stories.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export const Default: Story = {
4848
},
4949
};
5050

51+
export const Empty: Story = {
52+
args: {
53+
children: [],
54+
},
55+
};
56+
5157
export const WithButtons: Story = {
5258
name: 'With buttons',
5359
args: {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"target": "es6",
66
"lib": ["es6", "es7", "es2017", "dom"],
77
"sourceMap": true,
8+
"inlineSources": true,
89
"allowJs": false,
910
"jsx": "react",
1011
"moduleResolution": "node",

yarn.lock

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@
26172617
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
26182618
integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==
26192619

2620-
"@jridgewell/sourcemap-codec@^1.4.14":
2620+
"@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.4.15":
26212621
version "1.4.15"
26222622
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
26232623
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
@@ -4813,12 +4813,12 @@
48134813
"@types/react" "*"
48144814
"@types/reactcss" "*"
48154815

4816-
"@types/react-dom@^16.9.8":
4817-
version "16.9.19"
4818-
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.19.tgz#6a139c26b02dec533a7fa131f084561babb10a8f"
4819-
integrity sha512-xC8D280Bf6p0zguJ8g62jcEOKZiUbx9sIe6O3tT/lKfR87A7A6g65q13z6D5QUMIa/6yFPkNhqjF5z/VVZEYqQ==
4816+
"@types/react-dom@^18.2.8":
4817+
version "18.2.18"
4818+
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.18.tgz#16946e6cd43971256d874bc3d0a72074bb8571dd"
4819+
integrity sha512-TJxDm6OfAX2KJWJdMEVTwWke5Sc/E/RlnPGvGfS0W7+6ocy2xhDVQVh/KvC2Uf7kACs+gDytdusDSdWfWkaNzw==
48204820
dependencies:
4821-
"@types/react" "^16"
4821+
"@types/react" "*"
48224822

48234823
48244824
version "11.0.4"
@@ -4844,15 +4844,6 @@
48444844
"@types/scheduler" "*"
48454845
csstype "^3.0.2"
48464846

4847-
"@types/react@^16":
4848-
version "16.14.46"
4849-
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.14.46.tgz#42ac91aece416176e6b6127cd9ec9e381ea67e16"
4850-
integrity sha512-Am4pyXMrr6cWWw/TN3oqHtEZl0j+G6Up/O8m65+xF/3ZaUgkv1GAtTPWw4yNRmH0HJXmur6xKCKoMo3rBGynuw==
4851-
dependencies:
4852-
"@types/prop-types" "*"
4853-
"@types/scheduler" "*"
4854-
csstype "^3.0.2"
4855-
48564847
"@types/reactcss@*":
48574848
version "1.2.3"
48584849
resolved "https://registry.yarnpkg.com/@types/reactcss/-/reactcss-1.2.3.tgz#af28ae11bbb277978b99d04d1eedfd068ca71834"
@@ -11878,6 +11869,13 @@ magic-string@^0.25.2:
1187811869
dependencies:
1187911870
sourcemap-codec "^1.4.4"
1188011871

11872+
magic-string@^0.30.4:
11873+
version "0.30.5"
11874+
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.5.tgz#1994d980bd1c8835dc6e78db7cbd4ae4f24746f9"
11875+
integrity sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==
11876+
dependencies:
11877+
"@jridgewell/sourcemap-codec" "^1.4.15"
11878+
1188111879
make-dir@^2.0.0, make-dir@^2.1.0:
1188211880
version "2.1.0"
1188311881
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
@@ -14667,6 +14665,15 @@ rollup-plugin-commonjs@^10.1.0:
1466714665
resolve "^1.11.0"
1466814666
rollup-pluginutils "^2.8.1"
1466914667

14668+
rollup-plugin-dts@^6.0.2:
14669+
version "6.1.0"
14670+
resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-6.1.0.tgz#56e9c5548dac717213c6a4aa9df523faf04f75ae"
14671+
integrity sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw==
14672+
dependencies:
14673+
magic-string "^0.30.4"
14674+
optionalDependencies:
14675+
"@babel/code-frame" "^7.22.13"
14676+
1467014677
rollup-plugin-node-resolve@^5.2.0:
1467114678
version "5.2.0"
1467214679
resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz#730f93d10ed202473b1fb54a5997a7db8c6d8523"

0 commit comments

Comments
 (0)