acdlite / redux-router

Redux bindings for React Router – keep your router state inside your Redux store
MIT License
2.3k stars 216 forks source link

Implement UMD build scripts #258

Closed Morfent closed 8 years ago

Morfent commented 8 years ago

This allows redux-router to be run in the browser and hosted on CDNs. Redux-router is available in the browser as window.ReduxRouter.

Scarysize commented 8 years ago

Why is envify necessary?

Morfent commented 8 years ago

@It's useful if there's code here that relies on process.env being a specific value, but looking through it, it's not used at all here. Should I take it out or leave it in in case it does get used in the future?

Scarysize commented 8 years ago

Yeah, please remove it :-) We can always re-add it, if it´s ever necessary.

Morfent commented 8 years ago

Removed.

Scarysize commented 8 years ago

Hey, it would be nice if you could modify the package.json accordingly. So the UMD build can be served by npmcdn.com.

Take a look at the bottom section "Suggested Workflow" here: https://npmcdn.com/#/

Scarysize commented 8 years ago

@Morfent Are you still going to fix this?

Morfent commented 8 years ago

I will when I get around to it. I have other priorities i need to deal with first before i can get back to this.

Scarysize commented 8 years ago

Okay, thanks for the feedback. I will leave this open then.

Morfent commented 8 years ago

That should do it, I believe.

Scarysize commented 8 years ago

LGTM, @mjrussell could you give this a quick look, too.

mjrussell commented 8 years ago

Hm Im not as familiar with UMD. Do you need to add lib to the files now that its defined to include dist?

Morfent commented 8 years ago

I'm not entirely sure, since I've never published an npm package before. Checking the UDM files created when running npm publish, they seem fine. Here's the output from attempting to run npm publish, if it helps:

morfent@kennel:~/Documents/redux-router> npm publish

> redux-router@2.0.0 prepublish /home/morfent/Documents/redux-router
> npm run clean && mkdir dist && npm run build

/
> redux-router@2.0.0 clean /home/morfent/Documents/redux-router
> rimraf lib && rimraf dist && rimraf server.js

/
> redux-router@2.0.0 build /home/morfent/Documents/redux-router
> npm run build:commonjs && npm run build:umd && npm run build:umd:min

/
> redux-router@2.0.0 build:commonjs /home/morfent/Documents/redux-router
> babel src --out-dir lib && cp lib/serverModule.js server.js

src/ReduxRouter.js -> lib/ReduxRouter.js
src/__tests__/ReduxRouter-test.js -> lib/__tests__/ReduxRouter-test.js
src/__tests__/init.js -> lib/__tests__/init.js
src/__tests__/reduxReactRouter-test.js -> lib/__tests__/reduxReactRouter-test.js
src/actionCreators.js -> lib/actionCreators.js
src/client.js -> lib/client.js
src/constants.js -> lib/constants.js
src/historyMiddleware.js -> lib/historyMiddleware.js
src/index.js -> lib/index.js
src/isActive.js -> lib/isActive.js
src/matchMiddleware.js -> lib/matchMiddleware.js
src/reduxReactRouter.js -> lib/reduxReactRouter.js
src/replaceRoutesMiddleware.js -> lib/replaceRoutesMiddleware.js
src/routeReplacement.js -> lib/routeReplacement.js
src/routerStateEquals.js -> lib/routerStateEquals.js
src/routerStateReducer.js -> lib/routerStateReducer.js
src/server.js -> lib/server.js
src/serverModule.js -> lib/serverModule.js
src/useDefaults.js -> lib/useDefaults.js
|
> redux-router@2.0.0 build:umd /home/morfent/Documents/redux-router
> NODE_ENV=development browserify -s ReduxRouter --detect-globals lib/index.js -o dist/redux-router.js

|
> redux-router@2.0.0 build:umd:min /home/morfent/Documents/redux-router
> NODE_ENV=production browserify -s ReduxRouter --detect-globals lib/index.js | uglifyjs -c warnings=false -m > dist/redux-router.min.js

npm ERR! Linux 4.1.27-24-default
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "publish"
npm ERR! node v4.4.5
npm ERR! npm  v2.15.5
npm ERR! code ENEEDAUTH

npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

npm ERR! Please include the following file with any support request:
npm ERR!     /home/morfent/Documents/redux-router/npm-debug.log
mjrussell commented 8 years ago

Looking at react-router-redux's setup seems to indicate we should - https://github.com/reactjs/react-router-redux/blob/master/package.json

Morfent commented 8 years ago

I added the list of files that react-redux-router uses in package.json.

mjrussell commented 8 years ago

Looks good to me

Scarysize commented 8 years ago

Nice!

Scarysize commented 8 years ago

I published a version with your update to npm.