Use rollup for react-json-tree

This commit is contained in:
Nathan Bierema 2022-01-08 23:28:54 -05:00
parent 288e975b17
commit 41fe530bdb
22 changed files with 128 additions and 98 deletions

View File

@ -17,7 +17,6 @@
"author": "romseguy",
"files": [
"dist",
"lib",
"src"
],
"main": "dist/d3-state-visualizer.cjs.js",
@ -30,7 +29,7 @@
},
"scripts": {
"build": "rollup -c",
"clean": "rimraf lib dist",
"clean": "rimraf dist",
"lint": "eslint . --ext .ts",
"type-check": "tsc --noEmit",
"prepack": "yarn run clean && yarn run build",

View File

@ -17,7 +17,6 @@ const config = [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],
@ -36,7 +35,6 @@ const config = [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],
@ -53,7 +51,6 @@ const config = [
plugins: [
typescript(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],

View File

@ -11,7 +11,7 @@ It was created by [@romseguy](https://github.com/romseguy) and merged from [`rom
```javascript
import d3 from 'd3';
import d3tooltip from 'd3tooltip';
import { tooltip } from 'd3tooltip';
const DOMNode = document.getElementById('chart');
const root = d3.select(DOMNode);

View File

@ -13,7 +13,6 @@
"license": "MIT",
"author": "romseguy",
"files": [
"lib",
"dist",
"src"
],
@ -27,7 +26,7 @@
},
"scripts": {
"build": "rollup -c",
"clean": "rimraf lib dist",
"clean": "rimraf dist",
"lint": "eslint . --ext .ts",
"type-check": "tsc --noEmit",
"prepack": "yarn run clean && yarn run build",

View File

@ -17,7 +17,6 @@ const config = [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],
@ -36,7 +35,6 @@ const config = [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],
@ -53,7 +51,6 @@ const config = [
plugins: [
typescript(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],

View File

@ -16,7 +16,6 @@
"license": "MIT",
"author": "romseguy",
"files": [
"lib",
"dist",
"src"
],
@ -30,7 +29,7 @@
},
"scripts": {
"build": "rollup -c",
"clean": "rimraf lib dist",
"clean": "rimraf dist",
"test": "jest",
"lint": "eslint . --ext .ts",
"type-check": "tsc --noEmit",

View File

@ -17,7 +17,6 @@ const config = [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],
@ -36,7 +35,6 @@ const config = [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],
@ -53,7 +51,6 @@ const config = [
plugins: [
typescript(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],

View File

@ -15,7 +15,7 @@
"license": "MIT",
"author": "Alexander <alexkuz@gmail.com> (http://kuzya.org/)",
"files": [
"lib",
"dist",
"src"
],
"main": "dist/react-base16-styling.cjs.js",
@ -27,7 +27,7 @@
},
"scripts": {
"build": "rollup -c",
"clean": "rimraf lib",
"clean": "rimraf dist",
"test": "jest",
"lint": "eslint . --ext .ts",
"type-check": "tsc --noEmit",

View File

@ -11,7 +11,6 @@ const config = [
plugins: [
typescript(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],

View File

@ -15,7 +15,7 @@
"license": "MIT",
"author": "Alexander <alexkuz@gmail.com> (http://kuzya.org/)",
"files": [
"lib",
"dist",
"src"
],
"main": "dist/react-dock.cjs.js",
@ -27,7 +27,7 @@
},
"scripts": {
"build": "rollup -c",
"clean": "rimraf lib",
"clean": "rimraf dist",
"test": "jest",
"lint": "eslint . --ext .ts,.tsx",
"type-check": "tsc --noEmit",

View File

@ -11,9 +11,8 @@ const config = [
plugins: [
typescript(),
babel({
exclude: 'node_modules/**',
babelHelpers: 'runtime',
extensions: ['.ts'],
extensions: ['.ts', '.tsx'],
plugins: ['@babel/plugin-transform-runtime'],
}),
],

View File

@ -1,6 +1,6 @@
{
"presets": [
"@babel/preset-env",
["@babel/preset-env", { "targets": "defaults" }],
"@babel/preset-react",
"@babel/preset-typescript"
]

View File

@ -1,3 +1,2 @@
dist
examples
lib
umd

View File

@ -1,10 +1,14 @@
module.exports = {
extends: '../../eslintrc.ts.react.base.json',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
extends: '../../eslintrc.js.base.json',
overrides: [
{
files: ['*.ts', '*.tsx'],
extends: '../../eslintrc.ts.react.base.json',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
},
{
files: ['test/**/*.ts', 'test/**/*.tsx'],
extends: '../../eslintrc.ts.react.jest.base.json',

View File

@ -7,7 +7,7 @@ React JSON Viewer Component, Extracted from [redux-devtools](https://github.com/
### Usage
```jsx
import JSONTree from 'react-json-tree';
import { JSONTree } from 'react-json-tree';
// If you're using Immutable.js: `npm i --save immutable`
import { Map } from 'immutable';

View File

@ -1,6 +1,6 @@
import React from 'react';
import { Map } from 'immutable';
import JSONTree, { StylingValue } from 'react-json-tree';
import { JSONTree, StylingValue } from 'react-json-tree';
const getLabelStyle: StylingValue = ({ style }, nodeType, expanded) => ({
style: {

View File

@ -19,23 +19,20 @@
"Mihail Diordiev <zalmoxisus@gmail.com> (https://github.com/zalmoxisus)"
],
"files": [
"lib",
"src",
"umd"
"dist",
"src"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/react-json-tree.cjs.js",
"module": "dist/react-json-tree.esm.js",
"types": "dist/index.d.ts",
"unpkg": "dist/react-json-tree.umd.js",
"repository": {
"type": "git",
"url": "https://github.com/reduxjs/redux-devtools.git"
},
"scripts": {
"build": "yarn run build:types && yarn run build:js && yarn run build:umd && npm run build:umd:min",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
"build:umd": "rimraf ./umd && webpack --progress --config webpack.config.umd.ts",
"build:umd:min": "webpack --env production --progress --config webpack.config.umd.ts",
"clean": "rimraf lib umd",
"build": "rollup -c",
"clean": "rimraf umd",
"test": "jest",
"lint": "eslint . --ext .ts,.tsx",
"type-check": "tsc --noEmit",
@ -43,23 +40,26 @@
"prepublish": "yarn run type-check && yarn run lint && yarn run test"
},
"dependencies": {
"@babel/runtime": "^7.16.7",
"@types/prop-types": "^15.7.4",
"prop-types": "^15.8.0",
"react-base16-styling": "^0.8.2"
},
"devDependencies": {
"@babel/cli": "^7.16.7",
"@babel/core": "^7.16.7",
"@babel/eslint-parser": "^7.16.5",
"@babel/plugin-transform-runtime": "^7.16.7",
"@babel/preset-env": "^7.16.7",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.17",
"@types/react": "^17.0.38",
"@types/react-test-renderer": "^17.0.1",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"babel-loader": "^8.2.3",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^25.3.4",
@ -69,11 +69,12 @@
"react": "^17.0.2",
"react-test-renderer": "^17.0.2",
"rimraf": "^3.0.2",
"rollup": "^2.63.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.1",
"ts-jest": "^27.1.2",
"ts-node": "^10.4.0",
"typescript": "~4.5.4",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
"tslib": "^2.3.1",
"typescript": "~4.5.4"
},
"peerDependencies": {
"@types/react": "^16.3.0 || ^17.0.0",

View File

@ -0,0 +1,76 @@
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
const config = [
{
input: 'src/index.tsx',
output: {
name: 'ReactJsonTree',
file: 'dist/react-json-tree.umd.js',
format: 'umd',
globals: {
react: 'React',
},
},
plugins: [
typescript(),
resolve(),
commonjs(),
babel({
babelHelpers: 'runtime',
extensions: ['.ts', '.tsx'],
plugins: ['@babel/plugin-transform-runtime'],
}),
],
external: ['react'],
},
{
input: 'src/index.tsx',
output: {
name: 'ReactJsonTree',
file: 'dist/react-json-tree.umd.min.js',
format: 'umd',
globals: {
react: 'React',
},
},
plugins: [
typescript(),
resolve(),
commonjs(),
babel({
babelHelpers: 'runtime',
extensions: ['.ts', '.tsx'],
plugins: ['@babel/plugin-transform-runtime'],
}),
terser(),
],
external: ['react'],
},
{
input: 'src/index.tsx',
output: [
{ file: 'dist/react-json-tree.cjs.js', format: 'cjs' },
{ file: 'dist/react-json-tree.esm.js', format: 'esm' },
],
plugins: [
typescript(),
babel({
babelHelpers: 'runtime',
extensions: ['.ts', '.tsx'],
plugins: ['@babel/plugin-transform-runtime'],
}),
],
external: [
/@babel\/runtime/,
'react',
'prop-types',
'react-base16-styling',
],
},
];
export default config;

View File

@ -102,7 +102,7 @@ function getStateFromProps(props: Props) {
};
}
export default class JSONTree extends React.Component<Props, State> {
export class JSONTree extends React.Component<Props, State> {
static propTypes = {
data: PropTypes.any,
hideRoot: PropTypes.bool,

View File

@ -1,4 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"include": ["webpack.config.umd.ts"]
}

View File

@ -1,36 +0,0 @@
import * as path from 'path';
import * as webpack from 'webpack';
export default (env: { production?: boolean } = {}): webpack.Configuration => ({
mode: env.production ? 'production' : 'development',
entry: {
app: ['./src/index'],
},
output: {
library: 'ReactJsonTree',
libraryExport: 'default',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'umd'),
filename: env.production ? 'react-json-tree.min.js' : 'react-json-tree.js',
},
module: {
rules: [
{
test: /\.(js|ts)x?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
},
});

View File

@ -24252,19 +24252,22 @@ __metadata:
version: 0.0.0-use.local
resolution: "react-json-tree@workspace:packages/react-json-tree"
dependencies:
"@babel/cli": ^7.16.7
"@babel/core": ^7.16.7
"@babel/eslint-parser": ^7.16.5
"@babel/plugin-transform-runtime": ^7.16.7
"@babel/preset-env": ^7.16.7
"@babel/preset-react": ^7.16.7
"@babel/preset-typescript": ^7.16.7
"@babel/runtime": ^7.16.7
"@rollup/plugin-babel": ^5.3.0
"@rollup/plugin-commonjs": ^21.0.1
"@rollup/plugin-node-resolve": ^13.1.3
"@types/jest": ^27.4.0
"@types/node": ^16.11.17
"@types/prop-types": ^15.7.4
"@types/react": ^17.0.38
"@types/react-test-renderer": ^17.0.1
"@typescript-eslint/eslint-plugin": ^5.8.1
"@typescript-eslint/parser": ^5.8.1
babel-loader: ^8.2.3
eslint: ^8.6.0
eslint-config-prettier: ^8.3.0
eslint-plugin-jest: ^25.3.4
@ -24276,11 +24279,12 @@ __metadata:
react-base16-styling: ^0.8.2
react-test-renderer: ^17.0.2
rimraf: ^3.0.2
rollup: ^2.63.0
rollup-plugin-terser: ^7.0.2
rollup-plugin-typescript2: ^0.31.1
ts-jest: ^27.1.2
ts-node: ^10.4.0
tslib: ^2.3.1
typescript: ~4.5.4
webpack: ^5.65.0
webpack-cli: ^4.9.1
peerDependencies:
"@types/react": ^16.3.0 || ^17.0.0
react: ^16.3.0 || ^17.0.0