From 4199feceb3717a4d4fc446388dd57dcf65456589 Mon Sep 17 00:00:00 2001 From: neotob Date: Wed, 31 May 2023 10:19:02 +0200 Subject: [PATCH 1/5] change to rollup --- .eslintignore | 2 + CHANGELOG.md | 5 + package.json | 67 +- rollup.config.mjs | 74 + src/lib/DataTable/DataTableInterfaces.ts | 1 + test/DataTable/DataTable.test.tsx | 1 + .../__snapshots__/DataTable.test.tsx.snap | 2 +- tsconfig.json | 1 - tsconfig.microbundle.json | 5 - yarn.lock | 8187 ++++++++--------- 10 files changed, 4083 insertions(+), 4262 deletions(-) create mode 100644 .eslintignore create mode 100644 rollup.config.mjs delete mode 100644 tsconfig.microbundle.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..b01822b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +.eslintrc.cjs +rollup.config.mjs \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f56d50..8155d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Changed from `microbundle` to `rollup` for building the package +- Updated all the dependencies to the latest version + ## [2.5.0] - 2023-05-25 ### dependabot: \#33 Bump loader-utils from 1.4.0 to 1.4.2 diff --git a/package.json b/package.json index 6f46441..f93a8b7 100644 --- a/package.json +++ b/package.json @@ -9,15 +9,29 @@ }, "license": "MIT", "author": "Neolution", + "sideEffects": false, + "exports": { + "./package.json": "./package.json", + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.modern.js", + "require": "./dist/index.cjs" + } + }, "main": "dist/index.js", + "umd:main": "dist/index.umd.js", + "jsdelivr": "dist/index.umd.js", + "unpkg": "dist/index.umd.js", "module": "dist/index.modern.js", "source": "src/index.ts", + "jsnext:main": "dist/index.modern.js", + "types": "dist/index.d.ts", "files": [ "dist" ], "scripts": { - "build": "shx rm -rf dist && microbundle --jsx React.createElement --jsxFragment React.Fragment --jsxImportSource react --globals react/jsx-runtime=jsx --no-compress --tsconfig ./tsconfig.microbundle.json", - "build-storybook": "cross-env NODE_OPTIONS=--openssl-legacy-provider build-storybook", + "build": "rollup -c", + "build-storybook": "build-storybook", "lint": "eslint \"**/*.{ts,tsx}\" --cache --max-warnings 0", "prepack": "yarn build", "prepare-pr": "yarn prettier . --write && yarn lint && yarn build && yarn test\"", @@ -30,14 +44,19 @@ "test": "cross-env DEBUG_PRINT_LIMIT=100 jest", "tsc": "tsc" }, - "dependencies": {}, + "dependencies": { + "rollup-plugin-import-css": "^3.2.1" + }, "devDependencies": { - "@babel/core": "^7.17.9", + "@babel/core": "^7.21.8", "@fortawesome/fontawesome-svg-core": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-fontawesome": "^0.1.18", "@neolution-ch/react-pattern-ui": "^2.0.1", "@release-it/keep-a-changelog": "^3.1.0", + "@rollup/plugin-commonjs": "^24.1.0", + "@rollup/plugin-node-resolve": "^15.0.2", + "@rollup/plugin-terser": "^0.4.1", "@storybook/addon-actions": "^6.4.22", "@storybook/addon-essentials": "^6.4.22", "@storybook/addon-interactions": "^6.4.22", @@ -49,33 +68,35 @@ "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^14.0.4", "@types/jest": "^27.4.1", - "@types/node": "^17.0.23", - "@types/react": "^17.0.43", - "@types/react-dom": "^17.0.14", + "@types/node": "^18.16.3", + "@types/react": "^18.2.5", + "@types/react-dom": "^18.2.3", "@types/reactstrap": "^8.7.2", - "@typescript-eslint/eslint-plugin": "^5.18.0", - "@typescript-eslint/parser": "^5.18.0", - "babel-loader": "^8.2.4", + "@typescript-eslint/eslint-plugin": "^5.59.2", + "@typescript-eslint/parser": "^5.59.2", "bootstrap": "^4.0.0", - "concurrently": "^7.6.0", + "concurrently": "^8.0.1", "cross-env": "^7.0.3", - "eslint": "^8.12.0", - "eslint-config-prettier": "^8.5.0", - "eslint-import-resolver-typescript": "^2.7.1", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-storybook": "^0.5.8", - "gh-pages": "^3.2.3", + "eslint": "^8.39.0", + "eslint-config-prettier": "^8.8.0", + "eslint-import-resolver-typescript": "^3.5.5", + "eslint-plugin-import": "^2.27.5", + "eslint-plugin-storybook": "^0.6.12", + "gh-pages": "^5.0.0", "jest": "^27.5.1", - "microbundle": "^0.14.2", - "nodemon": "^2.0.20", - "prettier": "^2.6.2", + "nodemon": "^2.0.22", + "prettier": "^2.8.8", "react": "^17.0.2", "react-dom": "^17.0.2", - "reactstrap": "^8.9.0", - "release-it": "^15.7.0", + "reactstrap": "^9.1.9", + "release-it": "^15.10.3", + "rollup": "^3.21.4", + "rollup-plugin-peer-deps-external": "^2.2.4", + "rollup-plugin-typescript2": "^0.34.1", "shx": "^0.3.4", "ts-jest": "^27.1.4", - "typescript": "^4.6.3", + "typescript": "^5.0.4", + "webpack": "^5.82.0", "yalc": "^1.0.0-pre.53" }, "peerDependencies": { diff --git a/rollup.config.mjs b/rollup.config.mjs new file mode 100644 index 0000000..12647a9 --- /dev/null +++ b/rollup.config.mjs @@ -0,0 +1,74 @@ +import commonjs from "@rollup/plugin-commonjs"; +import nodeResolve from "@rollup/plugin-node-resolve"; +import external from "rollup-plugin-peer-deps-external"; +import terser from "@rollup/plugin-terser"; +import typescript from "rollup-plugin-typescript2"; +import css from "rollup-plugin-import-css"; + +const input = "src/index.ts"; + +const plugins = [ + css({ + output: "dist/index.css", + }), + external({ + includeDependencies: true, + }), + typescript({ + clean: true, + exclude: ["**/__tests__", "**/*.test.ts", "**/stories/**/*"], + }), + commonjs({ + include: /\/node_modules\//, + }), + nodeResolve(), + terser({ + output: { comments: false }, + compress: { + drop_console: true, + }, + }), +]; + +export default [ + { + input, + output: { + file: "dist/index.js", + format: "cjs", + name: "ReactHookFormComponents", + sourcemap: true, + globals: { react: "React" }, + exports: "named", + sourcemap: true, + interop: "auto", + }, + plugins, + }, + { + input, + output: { + file: "dist/index.modern.js", + format: "esm", + name: "ReactHookFormComponents", + sourcemap: true, + globals: { react: "React" }, + exports: "named", + sourcemap: true, + }, + plugins, + }, + { + input, + output: { + file: "dist/index.umd.js", + format: "umd", + name: "ReactHookFormComponents", + sourcemap: true, + globals: { react: "React" }, + exports: "named", + sourcemap: true, + }, + plugins, + }, +]; diff --git a/src/lib/DataTable/DataTableInterfaces.ts b/src/lib/DataTable/DataTableInterfaces.ts index 31c016b..b8ed0a7 100644 --- a/src/lib/DataTable/DataTableInterfaces.ts +++ b/src/lib/DataTable/DataTableInterfaces.ts @@ -150,6 +150,7 @@ export interface DataTablePredefinedActionLink { interface LinkProps { route: any; params?: RouteParams; + children: JSX.Element; } export interface DataTablePredefinedActionLinkGetParamsParams { diff --git a/test/DataTable/DataTable.test.tsx b/test/DataTable/DataTable.test.tsx index 9941b65..4846f07 100644 --- a/test/DataTable/DataTable.test.tsx +++ b/test/DataTable/DataTable.test.tsx @@ -2,6 +2,7 @@ import { fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import "@testing-library/jest-dom"; import React, { CSSProperties } from "react"; +import ReactDOM from "react-dom/client"; import { DataTable, DataTableStatic } from "src/lib/DataTable/DataTable"; import { DataTableColumnDescription, TableQueryResult, DataTableActions } from "src/lib/DataTable/DataTableInterfaces"; import { ColumnFilterType, ListSortDirection } from "src/lib/DataTable/DataTableTypes"; diff --git a/test/DataTable/__snapshots__/DataTable.test.tsx.snap b/test/DataTable/__snapshots__/DataTable.test.tsx.snap index 4b15742..4860f06 100644 --- a/test/DataTable/__snapshots__/DataTable.test.tsx.snap +++ b/test/DataTable/__snapshots__/DataTable.test.tsx.snap @@ -84,7 +84,7 @@ exports[`DataTable renders dynamic correctly 1`] = `