Use rollup for redux-devtools-intrument

This commit is contained in:
Nathan Bierema 2022-01-08 23:50:25 -05:00
parent 5d1ff2f5e5
commit 70449307c1
9 changed files with 60 additions and 19 deletions

View File

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

View File

@ -1 +1 @@
lib dist

View File

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

View File

@ -17,20 +17,19 @@
"license": "MIT", "license": "MIT",
"author": "Dan Abramov <dan.abramov@me.com> (http://github.com/gaearon)", "author": "Dan Abramov <dan.abramov@me.com> (http://github.com/gaearon)",
"files": [ "files": [
"lib", "dist",
"src" "src"
], ],
"main": "lib/instrument.js", "main": "dist/redux-devtools-instrument.cjs.js",
"types": "lib/instrument.d.ts", "module": "dist/redux-devtools-instrument.esm.js",
"types": "dist/instrument.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/reduxjs/redux-devtools.git" "url": "https://github.com/reduxjs/redux-devtools.git"
}, },
"scripts": { "scripts": {
"build": "yarn run build:types && yarn run build:js", "build": "rollup -c",
"build:types": "tsc --emitDeclarationOnly", "clean": "rimraf dist",
"build:js": "babel src --out-dir lib --extensions \".ts\" --source-maps inline",
"clean": "rimraf lib",
"test": "jest", "test": "jest",
"lint": "eslint . --ext .ts", "lint": "eslint . --ext .ts",
"type-check": "tsc --noEmit", "type-check": "tsc --noEmit",
@ -38,13 +37,16 @@
"prepublish": "yarn run type-check && yarn run lint && yarn run test" "prepublish": "yarn run type-check && yarn run lint && yarn run test"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.7",
"lodash": "^4.17.21" "lodash": "^4.17.21"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.16.7",
"@babel/core": "^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-env": "^7.16.7",
"@babel/preset-typescript": "^7.16.7", "@babel/preset-typescript": "^7.16.7",
"@rollup/plugin-babel": "^5.3.0",
"@types/jest": "^27.4.0", "@types/jest": "^27.4.0",
"@types/lodash": "^4.14.178", "@types/lodash": "^4.14.178",
"@types/node": "^16.11.17", "@types/node": "^16.11.17",
@ -56,8 +58,11 @@
"jest": "^27.4.5", "jest": "^27.4.5",
"redux": "^4.1.2", "redux": "^4.1.2",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.63.0",
"rollup-plugin-typescript2": "^0.31.1",
"rxjs": "^7.5.1", "rxjs": "^7.5.1",
"ts-jest": "^27.1.2", "ts-jest": "^27.1.2",
"tslib": "^2.3.1",
"typescript": "~4.5.4" "typescript": "~4.5.4"
}, },
"peerDependencies": { "peerDependencies": {

View File

@ -0,0 +1,23 @@
import typescript from 'rollup-plugin-typescript2';
import babel from '@rollup/plugin-babel';
const config = [
{
input: 'src/instrument.ts',
output: [
{ file: 'dist/redux-devtools-instrument.cjs.js', format: 'cjs' },
{ file: 'dist/redux-devtools-instrument.esm.js', format: 'esm' },
],
plugins: [
typescript(),
babel({
babelHelpers: 'runtime',
extensions: ['.ts'],
plugins: ['@babel/plugin-transform-runtime'],
}),
],
external: [/@babel\/runtime/, /lodash/],
},
];
export default config;

View File

@ -981,7 +981,7 @@ export interface Options<
/** /**
* Redux instrumentation store enhancer. * Redux instrumentation store enhancer.
*/ */
export default function instrument< export function instrument<
OptionsS, OptionsS,
OptionsA extends Action<unknown>, OptionsA extends Action<unknown>,
MonitorState = null, MonitorState = null,

View File

@ -1,7 +1,8 @@
import React, { Children, Component } from 'react'; import React, { Children, Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { connect, Provider, ReactReduxContext } from 'react-redux'; import { connect, Provider, ReactReduxContext } from 'react-redux';
import instrument, { import {
instrument,
EnhancedStore, EnhancedStore,
LiftedState, LiftedState,
LiftedStore, LiftedStore,

View File

@ -1,5 +1,5 @@
export { export {
default as instrument, instrument,
ActionCreators, ActionCreators,
ActionTypes, ActionTypes,
PerformAction, PerformAction,

View File

@ -4970,10 +4970,13 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "@redux-devtools/instrument@workspace:packages/redux-devtools-instrument" resolution: "@redux-devtools/instrument@workspace:packages/redux-devtools-instrument"
dependencies: dependencies:
"@babel/cli": ^7.16.7
"@babel/core": ^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-env": ^7.16.7
"@babel/preset-typescript": ^7.16.7 "@babel/preset-typescript": ^7.16.7
"@babel/runtime": ^7.16.7
"@rollup/plugin-babel": ^5.3.0
"@types/jest": ^27.4.0 "@types/jest": ^27.4.0
"@types/lodash": ^4.14.178 "@types/lodash": ^4.14.178
"@types/node": ^16.11.17 "@types/node": ^16.11.17
@ -4986,8 +4989,11 @@ __metadata:
lodash: ^4.17.21 lodash: ^4.17.21
redux: ^4.1.2 redux: ^4.1.2
rimraf: ^3.0.2 rimraf: ^3.0.2
rollup: ^2.63.0
rollup-plugin-typescript2: ^0.31.1
rxjs: ^7.5.1 rxjs: ^7.5.1
ts-jest: ^27.1.2 ts-jest: ^27.1.2
tslib: ^2.3.1
typescript: ~4.5.4 typescript: ~4.5.4
peerDependencies: peerDependencies:
redux: ^3.4.0 || ^4.0.0 redux: ^3.4.0 || ^4.0.0