dustingetz / react-cursor

Immutable state for React.js
1.03k stars 50 forks source link

Moved library over to CommonJS from AMD; added `dist` directory; updated example #3

Closed damassi closed 10 years ago

damassi commented 10 years ago

I know in many cases the debate between CommonJS and AMD is a strong one with valid points on both sides of the isle, but I felt that in the case of React one should stick with conventions, and the convention is generally CommonJS via Browserify and Webpack.

I've updated the library so that it now uses the module.exports idiom, and updated your grunt file to use Browserify. It simplifies things substantially, including removing the need for bower to handle external dependencies since those are now being pulled in through NPM.

In the dist folder I've also included three new files:

In the latter two files above, one uses the library by pointing to the exports like so:

var Cursor = require('./path/to/react-cursor').Cursor;
var ImmutableOptimizations = require('./path/to/react-cursor').ImmutableOptimizations;

... or, if you plan on publishing to NPM, simply

var Cursor = require('react-cursor').Cursor;
var ImmutableOptimizations = require('react-cursor').ImmutableOptimizations;

I know this is an opinionated PR (so feel free to ignore!), but I do believe that by eliminating Bower and Require.js the project has been simplified quite a bit as well as made compatible for use with NPM.

Let me know if you'd like any updates to be made!

dustingetz commented 10 years ago

Thank you! I will try to merge this today.

onceknown commented 10 years ago

:+1:

KyleAMathews commented 10 years ago

:+1:

dustingetz commented 10 years ago

@damassi , I am having a very frustrating time trying to bring the codebase under test using browserify. Can you point me to an example of a working test setup that uses browserify for the tests? (As I need to require in react-cursor as a library)

dustingetz commented 10 years ago

I have spent a lot of time and got pretty close with karma, karma-bro, jasmine, but can't quite get things to work after spending a whole day on it. @danielmiladinov took a couple whacks at it too.

damassi commented 10 years ago

Sure thing. I'll take a look when I get home

Sent from my iPhone

On Oct 21, 2014, at 4:06 PM, Dustin Getz notifications@github.com wrote:

@damassi , I am having a very frustrating time trying to bring the codebase under test using browserify. Can you point me to an example of a working test setup that uses browserify for the tests? (As I need to require in react-cursor as a library)

— Reply to this email directly or view it on GitHub.