-
Notifications
You must be signed in to change notification settings - Fork 10
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
Build process + random updates #1
Build process + random updates #1
Conversation
- add bili (rolloup wrapper) to compile code and make it available in umd and commonjs - add gitingore and npmignore - create dist builds on publish and test
Hi @marinko-peso, I would prefer to keep the repo small, so I suggest only adding the changes related to bili. Also, I'm not familiar with bili, is there any benefits by not using rollup in this case? Let me know if you think there is a problem with this, |
Hey @mathiasvr , I was already starting to worry you are not gonno answer :-) I respect your intent regarding the repo size and the lint style so I removed all the additional changes except gitignore which I need to prevent node_modules from being included. Its a standard js gitignore and won't do any harm. Thanks! P.S. I ran tests after update and all is passing |
Thanks for doing all this, but I don't think we need gitignore and the dist folder. I tried the umd build, but it does not seem to work in the browser because of the node EventEmitter, Anyway, I will take a look at it later, and replace the EventEmitter to make it easier to support the browser. |
Hey @mathiasvr , so I deleted dist folder but keep in mind it will get auto created once build is compiled. Its npm standard to keep versions of library in a dist directory. Seems you are not really catching whats failing here. If anyone tries to use this with webpack/babel configuration (so in browser technically) it will work up until they want to generate a production build. At that point in time UglifyJS is called which fails on the fact your library does not have an ES5 version and it can't understand what to do with it. Example of exception: In order to resolve this user would have to understand the problem and put a special exception just for this lib to also be processed by Babel, for example: When you publish a new version of the library with bili generated build webpack will automatically pull es5 version, like it does for all other libs out there, and UglifyJS will understand what to do with it. In the same time, when used in commonJS environment, commonJS module will be picked automatically. I encourage you to try it with webpack prod build and see the problem yourself. |
I try to only use .gitignore for things that are specific to the project. In this case a .gitignore that ignores the dist folder would actually make sense, but anyway, I use a global .gitignore for all library/framework/IDE related files. I tried webpack 4.12 with production flags, and I don't get any errors, but I don't know your exact setup. If an es5 build solves the problem, I think we should go with that for now. However, I have updated bili to produce a commonjs build instead, because the current umd build does not work directly in the browser. I hope this work for you, but since webpack uses the es build, it should not be a problem. |
Webpack 4.x has UglifyJS that supports ES6 so thats why you don't get an error. Most of the community is still on Webpack 3.x where UglifyJS doesn't work with ES6, and then it blows up. It does solve the problem, umd build would be the standard but this also works. ES build generated by bili is es5, so when webpack puts it in the bundle before uglifyJS its fully compatible. In short, now it runs with no exception on any version of webpack :-) UMD should work in the browser though, I'll double check that. |
@marinko-peso No problem, after all you were the one putting up with me. 😄 When reading up on this, I realized that many uses umd, but i guess i'm just hard to please. The reason umd does not currently work natively in the browser (without webpack), is because the library depends on the node As I see it, the best way is to separate the build into commonjs for most libraries, es for the newest, and an inlined iife for the browser. The only good argument I see for umd is to support amd, but is there honestly anyone who uses that anymore? And even in that case, I would only replace the iife with umd, and never refer it in Sorry for ranting, I did not expect this comment to be get this long, just my usual frustration over javascript tooling. ¯\_(ツ)_/¯ Anyway, I'm happy with how it works now 👍 |
Reason for this is mostly bili: currently this package is not working properly with webpack prod build, uglifyJS is failing on it and it needs to get compiled by babel by adding an exception for node_modules. This PR resolves that problem and makes it plug & play even in prod environment, while still working properly in commonJS environment.
I hope it gets accepted! :-)
P.S. Tests are passing with the compiled version (and the src)