Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add export field into package.json #982

Closed
wants to merge 8 commits into from
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- ![last commit](https://badgen.net/github/last-commit/reacttooltip/react-tooltip) -->

[download-image]: https://img.shields.io/npm/dm/react-tooltip.svg?style=flat-square
Expand All @@ -17,7 +18,7 @@
</a>
</p>

If you like the project, please give the project a GitHub 🌟
If you like the project, please give the project a GitHub 🌟

## Demo

Expand Down Expand Up @@ -56,6 +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.

### Using NPM package
Expand Down Expand Up @@ -121,11 +123,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)

Expand All @@ -145,7 +147,7 @@ You can use [`renderToStaticMarkup()` function](https://reactjs.org/docs/react-d
```jsx
import ReactDOMServer from 'react-dom/server';
[...]
<a
<a
data-tooltip-id="my-tooltip"
data-tooltip-html={ReactDOMServer.renderToStaticMarkup(<div>I am <b>JSX</b> content</div>)}
>
Expand Down Expand Up @@ -175,7 +177,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
Expand Down
6 changes: 3 additions & 3 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
Expand Down
15 changes: 5 additions & 10 deletions esbuild.config.prod.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand All @@ -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,
},
]
Expand Down
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@
"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",
"module": "dist/react-tooltip.mjs",
"types": "dist/react-tooltip.d.ts",
"exports": {
".": {
"require": "./dist/react-tooltip.cjs",
danielbarion marked this conversation as resolved.
Show resolved Hide resolved
"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"
},
"license": "MIT",
"private": false,
"author": "ReactTooltip",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
]
Expand Down