Skip to content

Commit

Permalink
Merge pull request #80 from vadymshymko/update-rollup-config
Browse files Browse the repository at this point in the history
Delete babel. Use tsc for build
  • Loading branch information
vadymshymko authored May 12, 2023
2 parents 84d9248 + 684bf58 commit ae2014a
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 1,729 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# react-clear-modal

[![npm version](https://img.shields.io/npm/v/react-clear-modal)](https://www.npmjs.com/package/react-clear-modal)
[![minified + gzip](https://img.shields.io/bundlephobia/minzip/react-clear-modal/latest)](https://bundlephobia.com/package/react-clear-modal)
[![minified + gzip](https://img.shields.io/bundlephobia/minzip/react-clear-modal/latest)](https://bundlephobia.com/package/react-clear-modal@latest)
[![typescript](https://badgen.net/npm/types/react-clear-modal)](https://unpkg.com/react-clear-modal/dist/index.d.ts)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/vadymshymko/react-clear-modal/blob/master/LICENSE)

Expand Down
20 changes: 0 additions & 20 deletions babel.config.js

This file was deleted.

20 changes: 6 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-clear-modal",
"version": "1.0.9",
"version": "2.0.0",
"description": "Simple and lightweight, fully controlled isomorphic (with SSR support) modal component for React.js",
"files": [
"dist/"
Expand All @@ -10,8 +10,7 @@
"types": "dist/index.d.ts",
"sideEffects": false,
"scripts": {
"build": "rm -rf dist && yarn lint && yarn generate-types && rollup -c",
"generate-types": "tsc --emitDeclarationOnly",
"build": "rm -rf dist && yarn lint && rollup -c",
"lint": "eslint . --ext .tsx",
"prepare": "husky install",
"prepublish": "yarn build",
Expand Down Expand Up @@ -40,18 +39,14 @@
},
"homepage": "https://github.com/vadymshymko/react-clear-modal#readme",
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.17.10",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.1",
"@rollup/plugin-typescript": "^11.1.0",
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^8.33.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
Expand All @@ -65,12 +60,9 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"rollup": "^3.13.0",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.5.0",
"typescript": "^5.0.2"
},
"dependencies": {
"core-js": "^3.27.2"
},
"peerDependencies": {
"@types/react": "^16.8 || ^17 || ^18",
"react": "^16.8 || ^17 || ^18",
Expand Down
13 changes: 5 additions & 8 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable import/no-extraneous-dependencies */
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';

export default {
input: 'src/index.tsx',
Expand All @@ -22,10 +23,6 @@ export default {
exports: 'auto',
},
],
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled', extensions: ['tsx'] }),
terser(),
],
plugins: [resolve(), commonjs(), typescript(), terser()],
external: ['react', 'react-dom'],
};
11 changes: 7 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function ReactClearModal({
disableCloseOnBgClick,
disableBodyScrollOnOpen,
disableRenderInPortal,
onClick,
style,
...wrapperProps
}: ReactClearModalProps) {
const [isReadyForRender, setIsReadyForRender] = useState(
Expand All @@ -52,8 +54,8 @@ function ReactClearModal({

const handleWrapperClick = useCallback(
(event: MouseEvent<HTMLDivElement>) => {
if (wrapperProps.onClick) {
wrapperProps.onClick(event);
if (onClick) {
onClick(event);
}

if (
Expand All @@ -65,7 +67,7 @@ function ReactClearModal({
onRequestClose();
}
},
[wrapperProps, onRequestClose, disableCloseOnBgClick]
[onClick, onRequestClose, disableCloseOnBgClick]
);

const handleContentKeyDown = useCallback(
Expand Down Expand Up @@ -102,7 +104,7 @@ function ReactClearModal({
position: 'fixed',
right: 0,
top: 0,
...wrapperProps.style,
...(style || {}),
}}
onClick={handleWrapperClick}
>
Expand All @@ -127,6 +129,7 @@ function ReactClearModal({
handleWrapperClick,
isOpen,
wrapperProps,
style,
preRender,
]);

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"incremental": false,
"importHelpers": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react",
"lib": ["dom", "dom.iterable", "esnext"],
"moduleResolution": "node",
"outDir": "./dist",
Expand Down
Loading

0 comments on commit ae2014a

Please sign in to comment.