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

Breaks imports #24

Open
tpettrov opened this issue Apr 7, 2021 · 4 comments
Open

Breaks imports #24

tpettrov opened this issue Apr 7, 2021 · 4 comments

Comments

@tpettrov
Copy link

tpettrov commented Apr 7, 2021

After adding to .babelrc config, reduces the bundle but breaks imports and is unusable.

image

versions:

"react": "^16.14.0",
"@babel/cli": "^7.13.14",
"@babel/core": "^7.13.14",
"recharts": "^2.0.8"

@martinschayna
Copy link

The same error in my project, versions:

    "babel-plugin-recharts": "2.0.0",
    "recharts": "2.0.9",

    "@babel/cli": "7.13.14",
    "@babel/core": "7.13.14",
    "@babel/node": "7.13.13",
    "@babel/parser": "7.13.13",
    "@babel/plugin-proposal-class-properties": "7.13.0",
    "@babel/plugin-proposal-decorators": "7.13.5",
    "@babel/plugin-proposal-export-default-from": "7.12.13",
    "@babel/plugin-proposal-export-namespace-from": "7.12.13",
    "@babel/plugin-proposal-object-rest-spread": "7.13.8",
    "@babel/plugin-syntax-dynamic-import": "7.8.3",
    "@babel/plugin-transform-object-assign": "7.12.13",
    "@babel/plugin-transform-react-constant-elements": "7.13.13",
    "@babel/plugin-transform-runtime": "7.13.10",
    "@babel/plugin-transform-template-literals": "7.13.0",
    "@babel/preset-env": "7.13.12",
    "@babel/preset-flow": "7.13.13",
    "@babel/preset-react": "7.13.13",
    "@babel/register": "7.13.14",

@burtyish
Copy link

burtyish commented May 26, 2021

Ran into the same issue. Watching this issue.

I don't recommend this, but here's a little trick I found that you could do if you must.
Since the recharts npm package is distributed with the source code included (for some reason), you could import each component specifically, like this:

import { BarChart } from "recharts/es6/chart/BarChart";
import { ResponsiveContainer } from "recharts/es6/component/ResponsiveContainer";
import { YAxis } from "recharts/es6/cartesian/YAxis";
import { XAxis } from "recharts/es6/cartesian/XAxis";
import { Bar } from "recharts/es6/cartesian/Bar";

or from recharts/src/... for the typescript source.

@cherepanov
Copy link

the same. on my setup this caused by TS option. and i see no difference compared with tree shaking by webpack

        "esModuleInterop": true,

@nahoc
Copy link

nahoc commented Nov 21, 2021

Ran into the same issue. Watching this issue.

I don't recommend this, but here's a little trick I found that you could do if you must. Since the recharts npm package is distributed with the source code included (for some reason), you could import each component specifically, like this:

import { BarChart } from "recharts/es6/chart/BarChart";
import { ResponsiveContainer } from "recharts/es6/component/ResponsiveContainer";
import { YAxis } from "recharts/es6/cartesian/YAxis";
import { XAxis } from "recharts/es6/cartesian/XAxis";
import { Bar } from "recharts/es6/cartesian/Bar";

or from recharts/src/... for the typescript source.

Yes, but this reverts the tree-shaking, so there is not point in doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants