From 86549eea0efaf1fd184ce88928a006e1e422c748 Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Fri, 10 Mar 2023 13:29:09 -0300 Subject: [PATCH 1/8] fix: use not minified files into package and add export field --- package.json | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 85d4e550..f9749ed6 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,16 @@ "postbuild": "npm run types && npm run bundlesize", "prepublishOnly": "npm run build" }, - "main": "dist/react-tooltip.cjs.min.js", - "module": "dist/react-tooltip.esm.min.js", + "main": "dist/react-tooltip.cjs.js", + "module": "dist/react-tooltip.esm.js", "types": "dist/react-tooltip.d.ts", + "exports": { + ".": "./dist/react-tooltip.cjs.js", + "./dist/*.js": "./dist/*.js", + "./dist/react-tooltip.css": "./dist/react-tooltip.css", + "./dist/react-tooltip.d.ts": "./dist/react-tooltip.d.ts", + "./package.json": "./package.json" + }, "license": "MIT", "private": false, "author": "ReactTooltip", From e68d4c0683e589e7d8289828c2eb8bb24c48c3ae Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Fri, 10 Mar 2023 14:07:53 -0300 Subject: [PATCH 2/8] docs: update readme.md with minified information --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 28c6bb7b..601ffeac 100755 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![npm download][download-image]][download-url] ![minified](https://badgen.net/bundlephobia/min/react-tooltip) ![minified gzip](https://badgen.net/bundlephobia/minzip/react-tooltip) + [download-image]: https://img.shields.io/npm/dm/react-tooltip.svg?style=flat-square @@ -17,7 +18,7 @@

-If you like the project, please give the project a GitHub 🌟 +If you like the project, please give the project a GitHub 🌟 ## Demo @@ -56,7 +57,7 @@ yarn add react-tooltip ## Usage > :warning: If you were already using `react-tooltip<=5.7.5`, you'll be getting some deprecation warnings regarding the `anchorId` prop and some other features. -In versions >=5.8.0, we've introduced the `data-tooltip-id` attribute, and the `anchorSelect` prop, which are our recommended methods of using the tooltip moving forward. Check [the docs](https://react-tooltip.com/docs/getting-started) for more details. +> In versions >=5.8.0, we've introduced the `data-tooltip-id` attribute, and the `anchorSelect` prop, which are our recommended methods of using the tooltip moving forward. Check [the docs](https://react-tooltip.com/docs/getting-started) for more details. ### Using NPM package @@ -121,11 +122,11 @@ Check [the V5 docs](https://react-tooltip.com/docs/getting-started) for more com You can import `node_modules/react-tooltip/dist/react-tooltip.[mode].js` into your page. Please make sure that you have already imported `react` and `react-dom` into your page. -mode: `esm` `cjs` `umd` +mode: `esm` `cjs` `iife` Don't forget to import the CSS file from `node_modules/react-tooltip/dist/react-tooltip.css` to set default styling. This needs to be done only once in your application. -PS: all the files have a minified version and a non-minified version. +PS: all the files have a minified version and a non-minified version and the default to be imported are the not minified files. ![image](https://user-images.githubusercontent.com/9615850/205637814-c0ef01ae-bd77-4e7f-b4bf-df502c71e5c3.png) @@ -145,7 +146,7 @@ You can use [`renderToStaticMarkup()` function](https://reactjs.org/docs/react-d ```jsx import ReactDOMServer from 'react-dom/server'; [...] -I am JSX content)} > @@ -175,7 +176,6 @@ import ReactDOMServer from 'react-dom/server'; [wwayne](https://github.com/wwayne) (inactive) - Creator of the original React Tooltip (V1.x ~ V4.x.) - We would gladly accept a new maintainer to help out! ## Contributing From f3c1fed8ca4e7a6fd75972e4ef11f18bd207aa6b Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Fri, 10 Mar 2023 14:09:49 -0300 Subject: [PATCH 3/8] docs: revert change by vs-code on save on readme.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 601ffeac..e85d1e23 100755 --- a/README.md +++ b/README.md @@ -57,7 +57,8 @@ yarn add react-tooltip ## Usage > :warning: If you were already using `react-tooltip<=5.7.5`, you'll be getting some deprecation warnings regarding the `anchorId` prop and some other features. -> In versions >=5.8.0, we've introduced the `data-tooltip-id` attribute, and the `anchorSelect` prop, which are our recommended methods of using the tooltip moving forward. Check [the docs](https://react-tooltip.com/docs/getting-started) for more details. + +In versions >=5.8.0, we've introduced the `data-tooltip-id` attribute, and the `anchorSelect` prop, which are our recommended methods of using the tooltip moving forward. Check [the docs](https://react-tooltip.com/docs/getting-started) for more details. ### Using NPM package From 72b26346f59506da226046583494a33900f7c33b Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Sun, 12 Mar 2023 00:23:25 -0300 Subject: [PATCH 4/8] chore: change generated files extension to match esmodules and commonjs extensions --- bundlesize.config.json | 6 +++--- esbuild.config.prod.mjs | 15 +++++---------- package.json | 11 +++++++---- rollup.config.prod.js | 4 ++-- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/bundlesize.config.json b/bundlesize.config.json index 2880c41a..11f7f95c 100644 --- a/bundlesize.config.json +++ b/bundlesize.config.json @@ -1,15 +1,15 @@ { "files": [ { - "path": "./dist/react-tooltip.cjs.min.js", + "path": "./dist/react-tooltip.min.cjs", "maxSize": "10 kB" }, { - "path": "./dist/react-tooltip.esm.min.js", + "path": "./dist/react-tooltip.min.mjs", "maxSize": "10 kB" }, { - "path": "./dist/react-tooltip.iife.min.js", + "path": "./dist/react-tooltip.min.iife.js", "maxSize": "10 kB" } ] diff --git a/esbuild.config.prod.mjs b/esbuild.config.prod.mjs index 695dabfd..264b637f 100644 --- a/esbuild.config.prod.mjs +++ b/esbuild.config.prod.mjs @@ -5,12 +5,12 @@ import fs from 'fs' const buildsConfig = [ { format: 'esm', - outfile: 'dist/react-tooltip.esm.js', + outfile: 'dist/react-tooltip.mjs', minify: false, }, { format: 'cjs', - outfile: 'dist/react-tooltip.cjs.js', + outfile: 'dist/react-tooltip.cjs', minify: false, }, { @@ -25,22 +25,17 @@ const buildsConfig = [ }, { format: 'esm', - outfile: 'dist/react-tooltip.esm.min.js', + outfile: 'dist/react-tooltip.min.mjs', minify: true, }, { format: 'cjs', - outfile: 'dist/react-tooltip.cjs.min.js', + outfile: 'dist/react-tooltip.min.cjs', minify: true, }, { format: 'iife', - outfile: 'dist/react-tooltip.iife.min.js', - minify: true, - }, - { - format: 'esm', - outfile: 'dist/react-tooltip.min.js', + outfile: 'dist/react-tooltip.min.iife.js', minify: true, }, ] diff --git a/package.json b/package.json index f9749ed6..68c184e6 100644 --- a/package.json +++ b/package.json @@ -18,12 +18,15 @@ "postbuild": "npm run types && npm run bundlesize", "prepublishOnly": "npm run build" }, - "main": "dist/react-tooltip.cjs.js", - "module": "dist/react-tooltip.esm.js", + "main": "dist/react-tooltip.cjs", + "module": "dist/react-tooltip.mjs", "types": "dist/react-tooltip.d.ts", "exports": { - ".": "./dist/react-tooltip.cjs.js", - "./dist/*.js": "./dist/*.js", + ".": { + "require": "./dist/react-tooltip.cjs", + "import": "./dist/react-tooltip.mjs", + "default": "./dist/react-tooltip.cjs" + }, "./dist/react-tooltip.css": "./dist/react-tooltip.css", "./dist/react-tooltip.d.ts": "./dist/react-tooltip.d.ts", "./package.json": "./package.json" diff --git a/rollup.config.prod.js b/rollup.config.prod.js index 8794ab45..fe5ccd79 100644 --- a/rollup.config.prod.js +++ b/rollup.config.prod.js @@ -27,11 +27,11 @@ const buildFormats = [ format: 'umd', }, { - file: 'dist/react-tooltip.cjs.js', + file: 'dist/react-tooltip.cjs', format: 'cjs', }, { - file: 'dist/react-tooltip.esm.js', + file: 'dist/react-tooltip.mjs', format: 'es', }, ] From 02340ff194f6c67e00e7eb0f0464d86afa69f6a7 Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Sun, 12 Mar 2023 12:34:25 -0300 Subject: [PATCH 5/8] chore: update package.json to add types into exports map Co-authored-by: Jaco --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 68c184e6..bd1a498f 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "types": "dist/react-tooltip.d.ts", "exports": { ".": { + "types": "./dist/react-tooltip.d.ts", "require": "./dist/react-tooltip.cjs", "import": "./dist/react-tooltip.mjs", "default": "./dist/react-tooltip.cjs" From e65d7da5371d75b5a9be734396b31d4573d9baad Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Mon, 13 Mar 2023 09:50:08 -0300 Subject: [PATCH 6/8] chore: point to minified files in package.json --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bd1a498f..0b741dff 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,15 @@ "postbuild": "npm run types && npm run bundlesize", "prepublishOnly": "npm run build" }, - "main": "dist/react-tooltip.cjs", - "module": "dist/react-tooltip.mjs", + "main": "dist/react-tooltip.min.cjs", + "module": "dist/react-tooltip.min.mjs", "types": "dist/react-tooltip.d.ts", "exports": { ".": { "types": "./dist/react-tooltip.d.ts", - "require": "./dist/react-tooltip.cjs", - "import": "./dist/react-tooltip.mjs", - "default": "./dist/react-tooltip.cjs" + "require": "./dist/react-tooltip.min.cjs", + "import": "./dist/react-tooltip.min.mjs", + "default": "./dist/react-tooltip.min.cjs" }, "./dist/react-tooltip.css": "./dist/react-tooltip.css", "./dist/react-tooltip.d.ts": "./dist/react-tooltip.d.ts", From e1213fc8694e181a1846cc6a8f6de96a517bc876 Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Mon, 13 Mar 2023 10:04:42 -0300 Subject: [PATCH 7/8] docs: update readme.md about default import files --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e85d1e23..c4e6f815 100755 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ mode: `esm` `cjs` `iife` Don't forget to import the CSS file from `node_modules/react-tooltip/dist/react-tooltip.css` to set default styling. This needs to be done only once in your application. -PS: all the files have a minified version and a non-minified version and the default to be imported are the not minified files. +PS: all the files have a minified version and a non-minified version and the default to be imported are the minified files. ![image](https://user-images.githubusercontent.com/9615850/205637814-c0ef01ae-bd77-4e7f-b4bf-df502c71e5c3.png) From 56037269ad04267209b60a7885e3981461ad46af Mon Sep 17 00:00:00 2001 From: Daniel Barion Date: Tue, 14 Mar 2023 17:33:23 -0300 Subject: [PATCH 8/8] chore: update rollup build to match this PR --- rollup.config.prod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup.config.prod.js b/rollup.config.prod.js index fe5ccd79..9b6b0723 100644 --- a/rollup.config.prod.js +++ b/rollup.config.prod.js @@ -96,7 +96,7 @@ const defaultOutputData = buildFormats.map(({ file, format }) => ({ // this step is just to build the minified css and es modules javascript const minifiedOutputData = buildFormats.map(({ file, format }) => ({ - file: file.replace('.js', '.min.js'), + file: file.replace('.js', '.min.js').replace('.cjs', '.min.cjs').replace('.mjs', '.min.mjs'), format, plugins: [...pluginsForCSSMinification, terser(), filesize()], }))