jeremyckahn / shifty

The fastest TypeScript animation engine on the web
https://jeremyckahn.github.io/shifty/doc/
MIT License
1.54k stars 88 forks source link

Rollup issue - not working #97

Closed andymans closed 6 years ago

andymans commented 7 years ago

When using rollup as a build system, I get the following error:

'tween' is not exported by 'node_modules/shifty/dist/shifty.js' https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

my import looks like:

import {tween} from 'shifty'

I've looked at your code, and clearly it is exported in the source folder. I've been able to resolve the issue by simply copying your source folder into my project and doing the import from there e.g.

import {tween} from '../myShiftySourceFolder/main.js'

jeremyckahn commented 7 years ago

Hi @andymans, thanks for reporting this! I haven't used Rollup, but I imagine that you're seeing this issue because the files in the dist directory are ES5-friendly Webpack build artifacts. It's my understanding that this is the preferred best practice, but there may be a better way to publish ES6-authored NPM packages like Shifty. As an alternative, you could also import Shifty's src/main.js from your node_modules directory.

I will leave this open until I have a chance to think of a more elegant solution!

andymans commented 7 years ago

No probs! Great work on Shifty btw :-)

jeremyckahn commented 7 years ago

Thank you! Having happy users makes it all worthwhile. 🙂

I found this Rollup wiki page that looks like a good solution. I'll play with this as soon as I get a chance!

jeremyckahn commented 7 years ago

I'm digging into this now — perhaps the solution is to integrate rollup-plugin-node-resolve into your build process? I'm not sure if it's preferable for libraries like Shifty to provide Rollup/ES6-friendly build artifacts in addition to the more widely-compatible ES5 artifacts, or for downstream projects like yours to tool around the syntax disparity. What do you think, @andymans?

In any case, I've started the feature/97/rollup-support branch, which so far just upgrades the build process to use Webpack 2, which is some tech debt I wanted to address before figuring out how to support additional build targets. @andymans, what does an ideal build artifact look like for your Rollup needs?

I'm happy to adhere to community best practices, I just need a little guidance on what they are currently. :-)

jeremyckahn commented 6 years ago

Closing due to inactivity.