Comments (20)
That's because I used webpack's bundling of requires rather than babel's. Your Spring
is exposed under require('react-motion').default
. If it was babel it'd have automatically added a line to make it work. Related: microsoft/TypeScript#2719
Same problem when you include it as a script tag. A bit annoying. For now the above method works but I'll look into whether webpack can do this too. I use webpack's require because for some reason, if I directly export UMD from babel, webpack doesn't know how to expose a Spring
afterward. Maybe a bundling expert can help me with this here.
from react-motion.
I'm not explaining this very well lol. @nkbt probably knows this better than I do.
from react-motion.
from react-motion.
Right, the only reason why I'm even bundling with webpack is for bower support. Thought it was convenient that I can kill two birds with one build. So, if we support bower/script tag, we still need that build, and that's the problem.
from react-motion.
from react-motion.
from react-motion.
from react-motion.
I've gradually removed bower support for my other repos. But to be fair, maybe we're a bit in an echo chamber here. Some friends the other day told me they were still using script tags. Dunno about the intersection of people using bower/script tag and those using react-motion
from react-motion.
I can fix this stuff
On Jul 14, 2015 8:24 AM, "Nikita Butenko" [email protected] wrote:
I'm surprised to see react ppl using bower
from react-motion.
from react-motion.
^ I know... that was one of the reasons I didn't want it. Lemme ask on Twitter or something.
from react-motion.
Yeah, let's support it, for now...
from react-motion.
This actually seems correct to me.
react-motion
export is an ES6 module, so it has Spring
as the default export, and some other named exports. It's not a bug or a mistake—it's just the way ES6 exports work.
If you don't want that behavior, you can go back to using module.exports = Spring
, but then you'd have to change other named exports to be statics
on Spring
.
Not a Webpack issue, is it?
from react-motion.
Even Babel can't “make it work” on the export side.
Babel does “interop import” on the import side: if you import an ES5-style module from Babel, it will “pretend” it has a default export.
But it can't turn an ES6 module into something consumable by ES5 code without .default
because that's just the spec.
from react-motion.
It's not a mistake, but Babel goes a step further and does
exports["default"] = test;
module.exports = exports["default"];
After which you can use var Spring = require('react-motion')
directly.
You know what, maybe there shouldn't be a default export for this library?
from react-motion.
Oh, you're right.
But let's make Spring
named export then? Problem solved :-)
from react-motion.
We can have the excuse that I might expose a Decay
component, heh
from react-motion.
After all it's not just one component..
And people can write
import { Spring } from 'react-motion'
and
var Spring = require('react-motion').Spring
and everyone's happy
from react-motion.
You already have a TransitionSpring
so it's fair deal now I think
from react-motion.
Okay, the mystery of the Century revealed. This is why people still use bower - Rails! Going to explore some ways to support bower without checking in pre-built code into a repo.
I'll make a PR if I come up with some reasonably good solution.
from react-motion.
Related Issues (20)
- Code in npm is different than github repo HOT 2
- How to reset automatically styles on animation end
- componentWillReceiveProps warning with React 16.9 HOT 18
- can a release be tagged? HOT 2
- how to use react-motion library with modals HOT 1
- Animating an element with a varying width HOT 1
- Need to maintain same build file locations HOT 2
- Duplicated elements when using Motion component HOT 1
- Functionality check (I'd just like some clarification) HOT 1
- how to know animation end ( position absolute change to relative)
- With class and hook Demo in a project
- Error on Rome toolchain init (package.json invalid author) HOT 1
- Is this project still active? HOT 10
- Release support for React 17 HOT 2
- Continously rotating without jumps between tours HOT 4
- is react-motion dependent on using jsx? HOT 1
- doesn't appear to cleanly install at the moment HOT 1
- Listing an array of authors in package.json breaks some tools that parse it
- Add support for prefers-reduced-motion
- Content is jumping on click HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-motion.