juliangarnier / anime

JavaScript animation engine
https://animejs.com
MIT License
50.42k stars 3.68k forks source link

Error with ES import #674

Open DB-CL opened 4 years ago

DB-CL commented 4 years ago

Describe the bug I cannot get this library to work with typescript, it will always pop this error :

index.ts:1:19 - error TS2307: Cannot find module 'animejs/lib/anime.es.js'.

1 import anime from 'animejs/lib/anime.es.js';
                    ~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.

To Reproduce Steps to reproduce the behavior:

  1. mkdir testanimejs && cd testanime js && npm init
  2. npm install animejs
  3. npm install @types/animejs

Create a file with import anime from 'animejs/lib/anime.es.js'; and a simple anime example inside

  1. npx tsc index.ts --target es6

And this error will pop.

Maybe I'm missing something but as far as I understand this example should work.

hblee12294 commented 4 years ago

Just use import anime from 'animejs'.

Take a look at the package.json: { ..., "module": "lib/anime.es.js", ...}, Webpack will import anime.es.js directly.