Skip to content

Commit

Permalink
Fix typescript (#18)
Browse files Browse the repository at this point in the history
* emit types and fix rollup-typescript

* fix emitted types
  • Loading branch information
chrisrzhou authored Jun 9, 2019
1 parent a66cf4b commit b715ad6
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.7](https://github.com/chrisrzhou/react-wordcloud/compare/v1.0.6...v1.0.7) (2019-06-08)

Fix emitted types.

## [1.0.6](https://github.com/chrisrzhou/react-wordcloud/compare/v1.0.5...v1.0.6) (2019-06-08)

- Support deterministic behavior for randomn layout and colors by configuring the `options.deterministic` field. This makes testing and creating fixed wordcloud views convenient.
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "react-wordcloud",
"version": "1.0.6",
"version": "1.0.7",
"description": "Simple React + D3 wordcloud component with powerful features.",
"main": "dist/index.js",
"module": "dist/index.module.js",
"types": "src/index.d.ts",
"types": "dist/index.d.ts",
"keywords": [
"react",
"d3",
Expand All @@ -26,7 +26,7 @@
"build:docs": "yarn docz build",
"clean": "rm -rf dist .docz",
"dev": "yarn docz dev",
"lint": "eslint --ext .js,.jsx,.ts,.tsx --fix src docs",
"lint": "yarn tsc && eslint --ext .js,.jsx,.ts,.tsx --fix src docs",
"prepare": "yarn clean && yarn build",
"size": "bundlesize"
},
Expand Down Expand Up @@ -69,7 +69,7 @@
"react-dom": "^16.8.4",
"rollup": "^1.6.0",
"rollup-plugin-babel": "^4.1.0",
"rollup-plugin-typescript": "^1.0.0",
"rollup-plugin-typescript2": "^0.21.1",
"tslib": "*",
"typescript": "^3.3.3333"
},
Expand Down
32 changes: 18 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
import { DEFAULT_EXTENSIONS } from '@babel/core';
import babel from 'rollup-plugin-babel';
import typescript from 'rollup-plugin-typescript';
import typescript from 'rollup-plugin-typescript2';

import pkg from './package.json';

export default [
{
input: 'src/index.tsx',
plugins: [
typescript({
clean: true,
}),
babel({
exclude: 'node_modules/**',
extensions: [...DEFAULT_EXTENSIONS, 'ts', 'tsx'],
}),
typescript(),
],
input: 'src/index.tsx',
output: [
{
exports: 'named',
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'esm',
},
],
external: [
'd3-array',
'd3-cloud',
Expand All @@ -24,16 +39,5 @@ export default [
'seedrandom',
'tippy.js',
],
output: [
{
exports: 'named',
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'esm',
},
],
},
];
1 change: 0 additions & 1 deletion src/index.d.ts

This file was deleted.

6 changes: 4 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const { useEffect } = React;
const MAX_LAYOUT_ATTEMPTS = 10;
const SHRINK_FACTOR = 0.95;

export * from './types';

export const defaultCallbacks: Callbacks = {
getWordTooltip: ({ text, value }: Word): string => `${text} (${value})`,
};
Expand Down Expand Up @@ -67,8 +69,8 @@ export interface Props {
function Wordcloud({
callbacks,
maxWords,
options,
minSize,
options,
size: initialSize,
words,
}: Props): React.ReactElement {
Expand Down Expand Up @@ -156,8 +158,8 @@ function Wordcloud({
selection,
computedWords,
mergedOptions,
random,
mergedCallbacks,
random,
);
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default function render(
selection: Selection,
words: Word[],
options: Options,
random: () => number,
callbacks: Callbacks,
random: () => number,
): void {
const {
getWordColor,
Expand Down
13 changes: 7 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"outDir": "./dist/",
"declaration": true,
"jsx": "react",
"module": "es2015",
"moduleResolution": "node",
"outDir": "dist",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"jsx": "react"
"target": "es5"
},
"include": ["./src/**/*"]
"include": ["src"]
}
37 changes: 27 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3980,7 +3980,7 @@ estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0:
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"
integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=

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

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

resolve@1.10.1:
version "1.10.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.1.tgz#664842ac960795bbe758221cdccda61fb64b5f18"
integrity sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==
dependencies:
path-parse "^1.0.6"

resolve@^1.10.0, resolve@^1.10.1, resolve@^1.3.2, resolve@^1.7.1, resolve@^1.8.1:
version "1.11.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e"
Expand Down Expand Up @@ -7869,15 +7876,25 @@ rollup-plugin-babel@^4.1.0:
"@babel/helper-module-imports" "^7.0.0"
rollup-pluginutils "^2.3.0"

rollup-plugin-typescript@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript/-/rollup-plugin-typescript-1.0.1.tgz#86565033b714c3d1f3aba510aad3dc519f7091e9"
integrity sha512-rwJDNn9jv/NsKZuyBb/h0jsclP4CJ58qbvZt2Q9zDIGILF2LtdtvCqMOL+Gq9IVq5MTrTlHZNrn8h7VjQgd8tw==
rollup-plugin-typescript2@^0.21.1:
version "0.21.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.21.1.tgz#91cea787c5282762f4849e334cbef6a9fdaa7564"
integrity sha512-jM2tn8/fUKDRmDtH++/6CHYHv2R9dxfXnuW0rxbOq1Zrxdsg4g6w+WwbK0X2ma21WQcT9l/U9bA3RO+2SBIJ/A==
dependencies:
resolve "^1.10.0"
rollup-pluginutils "^2.5.0"
fs-extra "7.0.1"
resolve "1.10.1"
rollup-pluginutils "2.6.0"
tslib "1.9.3"

rollup-pluginutils@2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.6.0.tgz#203706edd43dfafeaebc355d7351119402fc83ad"
integrity sha512-aGQwspEF8oPKvg37u3p7h0cYNwmJR1sCBMZGZ5b9qy8HGtETknqjzcxrDRrcAnJNXN18lBH4Q9vZYth/p4n8jQ==
dependencies:
estree-walker "^0.6.0"
micromatch "^3.1.10"

rollup-pluginutils@^2.3.0, rollup-pluginutils@^2.5.0:
rollup-pluginutils@^2.3.0:
version "2.8.1"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz#8fa6dd0697344938ef26c2c09d2488ce9e33ce97"
integrity sha512-J5oAoysWar6GuZo0s+3bZ6sVZAC0pfqKz68De7ZgDi5z63jOVZn1uJL/+z1jeKHNbGII8kAyHF5q8LnxSX5lQg==
Expand Down Expand Up @@ -8891,7 +8908,7 @@ tryer@^1.0.0:
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==

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

0 comments on commit b715ad6

Please sign in to comment.