Use rollup for redux-devtools-serialize

This commit is contained in:
Nathan Bierema 2022-01-09 15:57:20 -05:00
parent c0b1716be4
commit 4d1616680d
7 changed files with 69 additions and 21 deletions

View File

@ -1,3 +1,7 @@
{
"presets": ["@babel/preset-env", "@babel/preset-typescript"]
"presets": [
["@babel/preset-env", { "targets": "defaults" }],
"@babel/preset-typescript"
],
"plugins": ["@babel/plugin-transform-runtime"]
}

View File

@ -1 +1 @@
lib
dist

View File

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

View File

@ -12,8 +12,8 @@ Just pass the Immutable library to our class:
```js
import Immutable from 'immutable';
import Serialize from '@redux-devtools/serialize';
const { stringify, parse } = Serialize.immutable(Immutable);
import { immutable } from '@redux-devtools/serialize';
const { stringify, parse } = immutable(Immutable);
const data = Immutable.fromJS({ foo: 'bar', baz: { qux: 42 } });
const serialized = stringify(data);
@ -32,10 +32,10 @@ To parse a Record class back, you need to specify a reference to it:
```js
import Immutable from 'immutable';
import Serialize from '@redux-devtools/serialize';
import { immutable } from '@redux-devtools/serialize';
const ABRecord = Immutable.Record({ a: 1, b: 2 });
const { stringify, parse } = Serialize.immutable(Immutable, [ABRecord]);
const { stringify, parse } = immutable(Immutable, [ABRecord]);
const myRecord = new ABRecord({ b: 3 });
const serialized = stringify(myRecord);
@ -52,7 +52,7 @@ You can pass custom replacer and reviver functions to Serialize:
```js
import Immutable from 'immutable';
import Serialize from '@redux-devtools/serialize';
import { immutable } from '@redux-devtools/serialize';
function customReplacer(key, value, defaultReplacer) {
if (value === 1) {
@ -72,7 +72,7 @@ function customReviver(key, value, defaultReviver) {
return defaultReviver(key, value);
}
const { stringify, parse } = Serialize.immutable(
const { stringify, parse } = immutable(
Immutable,
null,
customReplacer,

View File

@ -12,17 +12,16 @@
},
"license": "MIT",
"author": "Mihail Diordiev <zalmoxisus@gmail.com> (https://github.com/zalmoxisus)",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/redux-devtools-serialize.cjs.js",
"module": "dist/redux-devtools-serialize.esm.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/reduxjs/redux-devtools.git"
},
"scripts": {
"build": "yarn run build:types && yarn run build:js",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir lib --extensions \".ts\" --source-maps inline",
"clean": "rimraf lib",
"build": "rollup -c",
"clean": "rimraf dist",
"test": "jest",
"lint": "eslint . --ext .ts",
"type-check": "tsc --noEmit",
@ -30,13 +29,16 @@
"prepublish": "yarn run type-check && yarn run lint && yarn run test"
},
"dependencies": {
"@babel/runtime": "^7.16.7",
"jsan": "^3.1.14"
},
"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-typescript": "^7.16.7",
"@rollup/plugin-babel": "^5.3.0",
"@types/jest": "^27.4.0",
"@types/jsan": "^3.1.2",
"@typescript-eslint/eslint-plugin": "^5.8.1",
@ -47,7 +49,10 @@
"immutable": "^4.0.0",
"jest": "^27.4.5",
"rimraf": "^3.0.2",
"rollup": "^2.63.0",
"rollup-plugin-typescript2": "^0.31.1",
"ts-jest": "^27.1.2",
"tslib": "^2.3.1",
"typescript": "~4.5.4"
},
"peerDependencies": {

View File

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

View File

@ -5159,10 +5159,13 @@ __metadata:
version: 0.0.0-use.local
resolution: "@redux-devtools/serialize@workspace:packages/redux-devtools-serialize"
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-typescript": ^7.16.7
"@babel/runtime": ^7.16.7
"@rollup/plugin-babel": ^5.3.0
"@types/jest": ^27.4.0
"@types/jsan": ^3.1.2
"@typescript-eslint/eslint-plugin": ^5.8.1
@ -5174,7 +5177,10 @@ __metadata:
jest: ^27.4.5
jsan: ^3.1.14
rimraf: ^3.0.2
rollup: ^2.63.0
rollup-plugin-typescript2: ^0.31.1
ts-jest: ^27.1.2
tslib: ^2.3.1
typescript: ~4.5.4
peerDependencies:
immutable: ^4.0.0