greensock / GSAP

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

Issue with webpack & Vue.js SSR (importing in Node.js) with v2.0.0 #271

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi,

I get the following error when using Vue.js (with Server Side Rendering) and webpack in Node:

C:\repositories\xyz\node_modules\gsap\TweenMax.js:13
import TweenLite, { TweenPlugin, Ease, Power0, Power1, Power2, Power3, Power4, Linear } from "./TweenLite";
       ^^^^^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:670:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at r (C:\repositories\xyz\node_modules\vue-server-renderer\build.js:8335:16)
    at Object.<anonymous> (webpack:/external "gsap/TweenMax":1:0)
    at __webpack_require__ (webpack:/webpack/bootstrap a9577780aaea39a228cb:19:0)
    at Object.<anonymous> (main.76d93e2d.js:2578:72)
    at __webpack_require__ (webpack:/webpack/bootstrap a9577780aaea39a228cb:19:0)
    at Object.<anonymous> (main.76d93e2d.js:2569:187)

I'm using this line in my code:

import {TweenMax, Power3} from 'gsap/umd/TweenMax';

It's the same with the non-UMD version:

import {TweenMax, Power3} from 'gsap/TweenMax';

Previous GSAP version worked.

jackdoyle commented 6 years ago

Hm, do you have a reduced test case you can share? That error message indicates that you were NOT using the UMD version that you thought you were (that code is in the root directory, the ES module). What version of Webpack are you using?

And to be clear, the stuff in the /umd/ directory is EXACTLY the same as the previous version (except with some bug fixes and new features). I'm sure we can get things working for you once we see a reduced test case.

jackdoyle commented 6 years ago

This should be resolved in 2.0.1. Happy tweening!

zipme commented 6 years ago

@jackdoyle Hi, I am using verison 2.0.1, still get the same error.

ghost commented 6 years ago

@jackdoyle @zipme The update resolved my issue - make sure you use the '/umd/' path.