GithubHelp home page GithubHelp logo

Comments (20)

chenglou avatar chenglou commented on May 6, 2024

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.

chenglou avatar chenglou commented on May 6, 2024

I'm not explaining this very well lol. @nkbt probably knows this better than I do.

from react-motion.

nkbt avatar nkbt commented on May 6, 2024

from react-motion.

chenglou avatar chenglou commented on May 6, 2024

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.

chenglou avatar chenglou commented on May 6, 2024

#30

from react-motion.

nkbt avatar nkbt commented on May 6, 2024

from react-motion.

nkbt avatar nkbt commented on May 6, 2024

from react-motion.

chenglou avatar chenglou commented on May 6, 2024

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.

nkbt avatar nkbt commented on May 6, 2024

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.

nkbt avatar nkbt commented on May 6, 2024

from react-motion.

chenglou avatar chenglou commented on May 6, 2024

^ I know... that was one of the reasons I didn't want it. Lemme ask on Twitter or something.

from react-motion.

chenglou avatar chenglou commented on May 6, 2024

Yeah, let's support it, for now...

from react-motion.

gaearon avatar gaearon commented on May 6, 2024

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.

gaearon avatar gaearon commented on May 6, 2024

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.

chenglou avatar chenglou commented on May 6, 2024

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.

gaearon avatar gaearon commented on May 6, 2024

Oh, you're right.
But let's make Spring named export then? Problem solved :-)

from react-motion.

chenglou avatar chenglou commented on May 6, 2024

We can have the excuse that I might expose a Decay component, heh

from react-motion.

gaearon avatar gaearon commented on May 6, 2024

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.

gaearon avatar gaearon commented on May 6, 2024

You already have a TransitionSpring so it's fair deal now I think

from react-motion.

nkbt avatar nkbt commented on May 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.