greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.83k stars 1.72k forks source link

Import using Rollup fails #265

Closed kraftwer1 closed 6 years ago

kraftwer1 commented 6 years ago

I can't get "gsap" to work using Rollup.js.

Steps to reproduce:

git clone https://github.com/kraftwer1/rollup-starter-app
npm install
npm run build

This line causes the error (while working fine using Webpack):

import { TweenLite } from 'gsap';

Message:

[!] Error: 'TweenLite' is not exported by node_modules/gsap/TweenMax.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
src/main.js (1:9)
1: import { TweenLite } from 'gsap';
kraftwer1 commented 6 years ago

Current workaround:

  commonjs: {
    namedExports: {
      "node_modules/gsap/TweenMax.js": ["TweenLite"]
    }
  }
jackdoyle commented 6 years ago

Ah, it looks like your project was expecting ES modules. Good news: we're about to release 1.20.5 which will distribute as ES modules by default via NPM. You can preview the files here: https://greensock.com/temp/GSAP-ES6.zip (only a valid link for the next few weeks). Does that resolve things for you? (You should be able to just drop those files into your node_modules/gsap folder). Notice there's a "umd" directory too in case you still need that older format (I doubt you will).

jackdoyle commented 6 years ago

1.20.5 is launched! Let us know if you run into any issues, but I'm pretty confident this will resolve your original one. Happy tweening!

kraftwer1 commented 6 years ago

@jackdoyle Fantastic, it works, great job!