-
Notifications
You must be signed in to change notification settings - Fork 21
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
ES6/UMD module #5
Comments
Great idea and I'm totally supportive of it, but I need some education on which tools to use and how to set them up (e.g. - webpack vs. rollup vs. browserify vs. parcel vs. babel). Shooting from the hip, I'd probably pick webpack on the browser side since it seems to have browser support; or pick babel on the node.js side (which would go away when Thoughts? |
I'm not an expert either, but from what I've seen browser wise webpack and browserify are mostly used in the final end project to collect or bundle all the libraries and convert it to whatever. Rollup is commonly used to build libraries, but webpack can be used to build libraries as well (it has a section in the manual). Babel is usually used as a plugin for these tools to transpile code. For the ES6 module you can remove the anonymous function around your code, then at the end add: export let WebAuthnHelpers = {
...
};
export {
Msg,
ServerResponse,
...
} Or just prefix the classes itself with For the UMD module rollup works pretty easy. Having the ES6 source code, run: Also for typescript users a type declaration file would be nice (index.d.ts). |
Ok, your post above and doing a bit more reading on rollup convinced me. Any suggestions for how to do distribution? e.g. - create a Let me know if you'd enjoy doing a PR for this. :) If not, it will probably be a couple weeks before I get to it since I'm currently playing around with Dockerizing the server. |
I'll see if I can create a PR. One thing that would change is that when used with a plain script tag in the browser the individual exports will be put inside a single object (e.g window.WebAuthSimpleApp.Msg rather than window.Msg). Though that probably is a good thing. I think rawgit would work fine with when the dist files are committed. It would require the build results to be committed (npm would not need that). Unpkg is also an option though I think it only supports UMD modules. |
Would you consider writing the module as an ES6 module (with export statements) and transform it into an UMD module (for example with rollup) to allow it to be used in all common environments?
The text was updated successfully, but these errors were encountered: