packages icon indicating copy to clipboard operation
packages copied to clipboard

update react router to 1.0.0-rc3 and add history

Open stopachka opened this issue 8 years ago • 6 comments

React router recently released a 1.0.x, and spun off into the main react-router module, and history.

https://github.com/rackt/react-router https://github.com/rackt/history

What would the steps be to get it into cljsjs? CC @ghedamat

Would be happy to help as well -- the one thing I am confused about is generating an externs file

stopachka avatar Oct 11 '15 15:10 stopachka

@stopachka there is a recommended tool to generate externs, you can look at

https://github.com/cljsjs/packages/blob/master/react-router/resources/cljsjs/react-router/common/react-router.ext.js#L1-L4

unfortunately react-router does not provide a global dist file anymore, until 0.13 it looked like they still exposed a dist version but iirc it was in CJS build format hence the tool was not able to parse it, now, at a first glance, it looks gone for good.

I guess the necessary steps would be to see if it's still possible to somehow build react-router into a globals like format so we can parse it or find another way to generate the externs.

than we'll need to include that build file into the cljsjs package as we need a single js to include.

regarding history, if the build file we produce includes history we can keep everything as is, if not we'll need another cljsjs package...

let me know if this makes any sense, this kind of problems is one of the caveats of projects moving to es6 modules.. maybe there are easier solutions that I'm just not aware of..

ghedamat avatar Oct 12 '15 14:10 ghedamat

p.s

just found out that they still have the global build

and it's in the UMD format

https://cdnjs.cloudflare.com/ajax/libs/react-router/1.0.0-rc1/ReactRouter.js

it works and we can use this as the js file for our package, but we should check if it includes the history library.

lastly we need a way to generate externs from the UMD format

ghedamat avatar Oct 12 '15 14:10 ghedamat

Nice, looks like it works!

var ReactRouter = {
    "__esModule": {},
    "Router": function () {},
    "Link": function () {},
    "IndexRoute": function () {},
    "Redirect": function () {},
    "Route": function () {},
    "History": {
        "contextTypes": {
            "history": function () {}
        },
        "componentWillMount": function () {}
    },
    "Lifecycle": {
        "propTypes": {
            "route": function () {}
        },
        "contextTypes": {
            "history": function () {},
            "route": function () {}
        },
        "_getRoute": function () {},
        "componentWillMount": function () {},
        "componentWillUnmount": function () {}
    },
    "RouteContext": {
        "propTypes": {
            "route": function () {}
        },
        "childContextTypes": {
            "route": function () {}
        },
        "getChildContext": function () {}
    },
    "useRoutes": function () {},
    "createRoutes": function () {},
    "RoutingContext": function () {},
    "PropTypes": {
        "falsy": function () {},
        "history": function () {},
        "location": function () {},
        "component": function () {},
        "components": function () {},
        "route": function () {}
    },
    "match": function () {},
    "default": function () {}
}

Will look more into history, test everything out, and update this thread.

stopachka avatar Oct 12 '15 15:10 stopachka

amazing, they might have improved the UMD format or something.. glad to hear that it's good now :)

ghedamat avatar Oct 12 '15 15:10 ghedamat

hello, any news? I'm interested in using a more recent version via cljsjs.

dgellow avatar Nov 06 '15 13:11 dgellow

ReactRouter is on version 2.0.1 now, so maybe the title of this issue should be changed.

domkm avatar Mar 17 '16 17:03 domkm