Skip to content

Commit b715ad6

Browse files
authored
Fix typescript (#18)
* emit types and fix rollup-typescript * fix emitted types
1 parent a66cf4b commit b715ad6

8 files changed

+65
-38
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.0.7](https://github.com/chrisrzhou/react-wordcloud/compare/v1.0.6...v1.0.7) (2019-06-08)
7+
8+
Fix emitted types.
9+
610
## [1.0.6](https://github.com/chrisrzhou/react-wordcloud/compare/v1.0.5...v1.0.6) (2019-06-08)
711

812
- Support deterministic behavior for randomn layout and colors by configuring the `options.deterministic` field. This makes testing and creating fixed wordcloud views convenient.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "react-wordcloud",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Simple React + D3 wordcloud component with powerful features.",
55
"main": "dist/index.js",
66
"module": "dist/index.module.js",
7-
"types": "src/index.d.ts",
7+
"types": "dist/index.d.ts",
88
"keywords": [
99
"react",
1010
"d3",
@@ -26,7 +26,7 @@
2626
"build:docs": "yarn docz build",
2727
"clean": "rm -rf dist .docz",
2828
"dev": "yarn docz dev",
29-
"lint": "eslint --ext .js,.jsx,.ts,.tsx --fix src docs",
29+
"lint": "yarn tsc && eslint --ext .js,.jsx,.ts,.tsx --fix src docs",
3030
"prepare": "yarn clean && yarn build",
3131
"size": "bundlesize"
3232
},
@@ -69,7 +69,7 @@
6969
"react-dom": "^16.8.4",
7070
"rollup": "^1.6.0",
7171
"rollup-plugin-babel": "^4.1.0",
72-
"rollup-plugin-typescript": "^1.0.0",
72+
"rollup-plugin-typescript2": "^0.21.1",
7373
"tslib": "*",
7474
"typescript": "^3.3.3333"
7575
},

rollup.config.js

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
1+
import { DEFAULT_EXTENSIONS } from '@babel/core';
12
import babel from 'rollup-plugin-babel';
2-
import typescript from 'rollup-plugin-typescript';
3+
import typescript from 'rollup-plugin-typescript2';
34

45
import pkg from './package.json';
56

67
export default [
78
{
9+
input: 'src/index.tsx',
810
plugins: [
11+
typescript({
12+
clean: true,
13+
}),
914
babel({
1015
exclude: 'node_modules/**',
16+
extensions: [...DEFAULT_EXTENSIONS, 'ts', 'tsx'],
1117
}),
12-
typescript(),
1318
],
14-
input: 'src/index.tsx',
19+
output: [
20+
{
21+
exports: 'named',
22+
file: pkg.main,
23+
format: 'cjs',
24+
},
25+
{
26+
file: pkg.module,
27+
format: 'esm',
28+
},
29+
],
1530
external: [
1631
'd3-array',
1732
'd3-cloud',
@@ -24,16 +39,5 @@ export default [
2439
'seedrandom',
2540
'tippy.js',
2641
],
27-
output: [
28-
{
29-
exports: 'named',
30-
file: pkg.main,
31-
format: 'cjs',
32-
},
33-
{
34-
file: pkg.module,
35-
format: 'esm',
36-
},
37-
],
3842
},
3943
];

src/index.d.ts

-1
This file was deleted.

src/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const { useEffect } = React;
1313
const MAX_LAYOUT_ATTEMPTS = 10;
1414
const SHRINK_FACTOR = 0.95;
1515

16+
export * from './types';
17+
1618
export const defaultCallbacks: Callbacks = {
1719
getWordTooltip: ({ text, value }: Word): string => `${text} (${value})`,
1820
};
@@ -67,8 +69,8 @@ export interface Props {
6769
function Wordcloud({
6870
callbacks,
6971
maxWords,
70-
options,
7172
minSize,
73+
options,
7274
size: initialSize,
7375
words,
7476
}: Props): React.ReactElement {
@@ -156,8 +158,8 @@ function Wordcloud({
156158
selection,
157159
computedWords,
158160
mergedOptions,
159-
random,
160161
mergedCallbacks,
162+
random,
161163
);
162164
}
163165
})

src/render.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export default function render(
1212
selection: Selection,
1313
words: Word[],
1414
options: Options,
15-
random: () => number,
1615
callbacks: Callbacks,
16+
random: () => number,
1717
): void {
1818
const {
1919
getWordColor,

tsconfig.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"compilerOptions": {
33
"allowSyntheticDefaultImports": true,
4-
"outDir": "./dist/",
4+
"declaration": true,
5+
"jsx": "react",
6+
"module": "es2015",
7+
"moduleResolution": "node",
8+
"outDir": "dist",
59
"sourceMap": true,
6-
"noImplicitAny": true,
7-
"module": "commonjs",
8-
"target": "es5",
9-
"jsx": "react"
10+
"target": "es5"
1011
},
11-
"include": ["./src/**/*"]
12+
"include": ["src"]
1213
}

yarn.lock

+27-10
Original file line numberDiff line numberDiff line change
@@ -3980,7 +3980,7 @@ estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0:
39803980
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"
39813981
integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=
39823982

3983-
estree-walker@^0.6.1:
3983+
estree-walker@^0.6.0, estree-walker@^0.6.1:
39843984
version "0.6.1"
39853985
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
39863986
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==
@@ -4444,7 +4444,7 @@ fs-constants@^1.0.0:
44444444
resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
44454445
integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
44464446

4447-
fs-extra@^7.0.0, fs-extra@^7.0.1:
4447+
fs-extra@7.0.1, fs-extra@^7.0.0, fs-extra@^7.0.1:
44484448
version "7.0.1"
44494449
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
44504450
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
@@ -7821,6 +7821,13 @@ resolve-url@^0.2.1:
78217821
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
78227822
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=
78237823

7824+
7825+
version "1.10.1"
7826+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.1.tgz#664842ac960795bbe758221cdccda61fb64b5f18"
7827+
integrity sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==
7828+
dependencies:
7829+
path-parse "^1.0.6"
7830+
78247831
resolve@^1.10.0, resolve@^1.10.1, resolve@^1.3.2, resolve@^1.7.1, resolve@^1.8.1:
78257832
version "1.11.1"
78267833
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e"
@@ -7869,15 +7876,25 @@ rollup-plugin-babel@^4.1.0:
78697876
"@babel/helper-module-imports" "^7.0.0"
78707877
rollup-pluginutils "^2.3.0"
78717878

7872-
rollup-plugin-typescript@^1.0.0:
7873-
version "1.0.1"
7874-
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript/-/rollup-plugin-typescript-1.0.1.tgz#86565033b714c3d1f3aba510aad3dc519f7091e9"
7875-
integrity sha512-rwJDNn9jv/NsKZuyBb/h0jsclP4CJ58qbvZt2Q9zDIGILF2LtdtvCqMOL+Gq9IVq5MTrTlHZNrn8h7VjQgd8tw==
7879+
rollup-plugin-typescript2@^0.21.1:
7880+
version "0.21.1"
7881+
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.21.1.tgz#91cea787c5282762f4849e334cbef6a9fdaa7564"
7882+
integrity sha512-jM2tn8/fUKDRmDtH++/6CHYHv2R9dxfXnuW0rxbOq1Zrxdsg4g6w+WwbK0X2ma21WQcT9l/U9bA3RO+2SBIJ/A==
78767883
dependencies:
7877-
resolve "^1.10.0"
7878-
rollup-pluginutils "^2.5.0"
7884+
fs-extra "7.0.1"
7885+
resolve "1.10.1"
7886+
rollup-pluginutils "2.6.0"
7887+
tslib "1.9.3"
7888+
7889+
7890+
version "2.6.0"
7891+
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.6.0.tgz#203706edd43dfafeaebc355d7351119402fc83ad"
7892+
integrity sha512-aGQwspEF8oPKvg37u3p7h0cYNwmJR1sCBMZGZ5b9qy8HGtETknqjzcxrDRrcAnJNXN18lBH4Q9vZYth/p4n8jQ==
7893+
dependencies:
7894+
estree-walker "^0.6.0"
7895+
micromatch "^3.1.10"
78797896

7880-
rollup-pluginutils@^2.3.0, rollup-pluginutils@^2.5.0:
7897+
rollup-pluginutils@^2.3.0:
78817898
version "2.8.1"
78827899
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz#8fa6dd0697344938ef26c2c09d2488ce9e33ce97"
78837900
integrity sha512-J5oAoysWar6GuZo0s+3bZ6sVZAC0pfqKz68De7ZgDi5z63jOVZn1uJL/+z1jeKHNbGII8kAyHF5q8LnxSX5lQg==
@@ -8891,7 +8908,7 @@ tryer@^1.0.0:
88918908
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
88928909
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
88938910

8894-
tslib@*, tslib@^1.8.1, tslib@^1.9.0:
8911+
tslib@*, tslib@1.9.3, tslib@^1.8.1, tslib@^1.9.0:
88958912
version "1.9.3"
88968913
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
88978914
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==

0 commit comments

Comments
 (0)