Add support for "legacy" compilation. Allow the library to be loaded with a simple <script> tag
gomball opened this issue · 4 comments
Hi all.
Let me start with a "thank you for this simple but great piece of code". It saves me hours and hours.
Right now the lib has two compilation targets: commonjs and esm. Its enough by far if you use the library in a compiled (i.e webpack) project. Today i found myself in the need of "importing" the library on a legacy, almost vanillajs, es5 web project. It's not possible to 'import' or 'require' anything, so i cannot consume the library in this kind of project.
FEATURE REQUEST:
Add a new build target to bundle the lib for browsers (using browserify) so it creates a property buildQuery
in the global 'window' object of the browsers.
NOTE: I opened a local brach with the new functionallity; everything seems to work fine. I would PR the changes but I cannot push the branch.
Hi @gomball. We're most welcome.
To submit a PR, you would first need to fork the repository (which will create gomball/odata-query and from there you should be able to submit one to techniq/odata-query
.
For direct browser support, this might be attainable by creating another tsconfig.*.json file with another module type, but I don't see IIFE. @Sayan751 setup our typescript build in the past, maybe he has some thoughts? I'd like to not complicate the build too much though.
Hi Sean, and thanks for your quick respond and analysis.
Here the diff with master: master...gomball:feature/browserify, so you and @Sayan751 can evaluate the complexity it adds. I think it would not be necessary to modify the build pipeline.
Speaking on TS, the only change is the exclusion of the new .ts entry point for the current compolation targets (cjs and esm)
...just thinking on it...
maybe adding a tsconfig.browser.json
and pass it to tsify would add consistency between compilation targets. I mean: one tsconfig file for each target...
or even using directly the cjs compiled bundle as browserify input