tweenjs / tween.js

JavaScript/TypeScript animation engine
https://tweenjs.github.io/tween.js/
Other
9.82k stars 1.41k forks source link

Provide an ES6 build of tween.js #459

Closed Mugen87 closed 5 years ago

Mugen87 commented 5 years ago

We are using tween.js in several three.js demos e.g. css3d_periodictable. The example code is currently migrated to ES6 modules and it would be great if also external libraries like tween.js can be included via ES6 imports. So something like:

import TWEEN from `./path/to/our/tween.module.js`;
mikebolt commented 5 years ago

Hi Michael. You can import tween.js after adding this line to the end of Tween.js:

export {TWEEN};

I plan to add a script that will do this for you and place the result in tween.es6.js. I also plan to have this done automatically by the CI.

On Fri, Jun 21, 2019 at 2:14 AM Michael Herzog notifications@github.com wrote:

We are using tween.js in several three.js demos e.g. css3d_periodictable https://threejs.org/examples/css3d_periodictable. The example code is currently migrated to ES6 modules and it would be great if also external libraries like tween.js can be included via ES6 imports. So something like:

import TWEEN from ./path/to/our/tween.module.js;

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tweenjs/tween.js/issues/459?email_source=notifications&email_token=AAQJVP7BBJNPRH5RGKUIIWLP3SLX5A5CNFSM4H2PHPCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G25IQEQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQJVP3FJUEE5K6ZY3TMYM3P3SLX5ANCNFSM4H2PHPCA .

Mugen87 commented 5 years ago

I plan to add a script that will do this for you and place the result in tween.es6.js. I also plan to have this done automatically by the CI.

Sounds good! Definitely better than doing a manual modification.

dirk-ecker commented 5 years ago

This actually works:

import TWEEN from '@tweenjs/tween.js'

mikebolt commented 5 years ago

To use tween.js as an ES6 module follow these steps:

  1. npm i @tweenjs/tween.js
  2. npm run build
  3. Copy dist/tween.esm.js somewhere
  4. Use an import statement such as import TWEEN from './js/tween.esm.js';