fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.58k stars 692 forks source link

error in react-toastify/libs/index.js:1 when running tests #228

Closed abenhamdine closed 6 years ago

abenhamdine commented 6 years ago

Since upgrading to version 4.2.0 to version 4.2.2, when I run tests with ts-jest I get the following error :

 /home/arhia/Documents/projects/payroll-app-next/client/node_modules/react-toastify/lib/index.js:1

 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import ToastContainer from './components/ToastContainer';

  ^^^^^^^^^^^^^^

    SyntaxError: Unexpected identifier

ToastContainer seems properly exported/imported in that file, so I don't understand the meaning of this error.

Our configuration : "react-toastify": "4.2.2", "react-scripts": "1.1.5" "react-app-rewire-typescript": "2.0.2", "react-app-rewired": "1.5.2",

Could someone provide some hints ?

fkhadra commented 6 years ago

@abenhamdine did you upgrade any other dependencies like babel, babel-core ?

abenhamdine commented 6 years ago

No, I'm still on babel 6.x, I didn't upgrade any of the babel suite :


"babel-core": "6.26.3",
"babel-plugin-import": "1.8.0",
"babel-preset-react-app": "3.1.2",
fkhadra commented 6 years ago

Can you delete the folder react-toastify under node_modules and reinstall it?

lib/index.js look normally like this:

import ToastContainer from './components/ToastContainer';
import { Bounce, Slide, Zoom, Flip } from './components/Transitions';
import toast from './toast';
import cssTransition from './utils/cssTransition';
export { ToastContainer, toast, cssTransition, Bounce, Slide, Zoom, Flip };

Could you share the content of the lib/index.js file.

Thanks

fkhadra commented 6 years ago

I'm able to reproduce the issue.

fkhadra commented 6 years ago

Since I upgraded to babel7, I don't transform the import and export statement anymore. I'll revert that behavior.

fkhadra commented 6 years ago

@abenhamdine the issue is fixed now.

👍

abenhamdine commented 6 years ago

thx a lot ! :+1: :dancer: