-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builds a UMD file for the browser when publishing. #8
Conversation
Neat approach! I rebased my tests on this version and updated them to WARNING in ./build/fetch-browser.js
Critical dependencies:
1:486-493 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./build/fetch-browser.js 1:486-493 The browserify build works fine, and makes no complaint. A slight disadvantage to this approach is that To try to dodge this warning, do you think it would be worth shipping the CommonJS and UMD builds separately? Here's the branch with the tests: https://github.com/paulmelnikow/fetch-ponyfill/tree/test_umd_version |
"brfs": "1.4.0", | ||
"browserify": "13.0.0", | ||
"mkdirp": "0.5.1", | ||
"node-fetch": "1.5.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For require('fetch-ponyfill')()
to work from Node, node-fetch
needs to stay in dependencies
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, good catch.
I have an idea on how to make this leaner. It means ditching browserify and making a hand rolled builder. I'd rather not separate UMD stuff where possible, but hand rolling can make it a lot smaller. I'll experiment... |
ef86afa
to
daa2566
Compare
@paulmelnikow Take a look now. There's still a bit of module fluff in there, but the rest is minifier friendly. It's pretty hacktastic, but then so was the original. |
It also fixes an issue of the existing version not working in a web worker without manually passing in config. |
Builds clean, and minifies! I like it. 👍 When you publish, it looks like You can either use "files": [
"fetch-node.js",
"build/fetch-browser.js"
], That seems to be the right incantation. You can use |
Odd. That should have worked. In any case, including the files list is a good idea (less stuff in the tar ball). Nice catch! I'll update. |
Added and checked, seems to be working. |
Looks good! |
84465de
to
b874cb7
Compare
Stoked! Would you mind doing an npm release so I can try to integrate it? |
No problem. I'll bump the whatwg-fetch version and release it. |
Released as v1.0.0 (tracking whatwg version). |
We started integrating this today, and it's working great! |
This PR coaxes browserify into making a standalone build. This allows the built file to be used in AMD environments as well as a browser global.
@paulmelnikow This is an alternative to #5.