-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Consider dropping JQuery / typescript conversion ? #1084
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
Comments
for sure and one of the biggest topic! It would have been great to first drop Jquery-UI (which is dead) when the original owner added D&D plugin support back in 0.3.0 but that never happened even thought that was the plan... In parallel I looked at removing jq from the main code (we use and return that type in a lot of places so API would have to change as well) and using cash as 5k gzip replacement (I have a locally modified version that suit our needs) in the meantime before making all native calls. http://youmightnotneedjquery.com has good info on replacement, and with modern browser support there isn't really a need for jq. I would love to have community contributions to make that happen ! if someone can do the drag&drop jquery-ui part, I could take care of the main code... I already reduced jqui to 1/5th it's size (custom build) and hide it in for now (bundle just what's used) but we need more. |
Thanks @adumesny this is really great news! We use gridstack for the VoilΓ project which turns Jupyter notebooks into standalone web applications. We have a templating system that allows changing the behavior to e.g. transform a notebook in a slideshow, or into a dashboards. The voilΓ -gridstack template makes use of gridstack: https://blog.jupyter.org/voila-gridstack-template-8a431c2b353e For 2020, we are considering to push voila-gridstack forward but the upgrade of gridstack to a more recent stack will be necessary. If we move forward with this plan, we should be able to put some cycles into GridstackJS and help with the upgrade. I'll keep you posted. |
That would be awesome as I don't have the bandwidth to do it all... but really want to remove JQ as well. Would be nice to convert project to Typescript as well (and generate JS) to make it easier to maintain and take advantage of newer features. |
Typescript would be a great change, since you can split up the code in modules. But why do you want to change jQuery for cash? What (in your opinion) are the advantages over Standard JS/DOM Objects/Methods? |
cash would only be a temporary step (if at all) as there are a lot of calls and return signatures that would need changing. |
if you explained what you mean by "D&D replacement", I would gladly help you. would it be possible to include cash in the final bundle, so gridstack does not need any dependencies/global modules? |
we use jqueryUI today to do the drag, drop, resize, move, animation - that part of the code would have to be replaced FIRST before we can consider removing JQuery (which has easier replacement API and tiny libs like cash) |
FYI as a first step I will be dropping JQuery from all APIs and dependencies so you will only need to include you will have to create a grid / item using these now: var grid = GridStack.init( opt );
grid.addWidget('<div><div class="grid-stack-item-content">item 1</div></div>', nodeOpt ); I already have some of the changes done locally and will be releasing an official v1.0.0 soon with these changes. Please comment and let me know if you can help migrate the internal code, especially the drag&drop replacement which I have not looked at yet. Update: branch https://github.com/adumesny/gridstack.js/tree/jq will contain the "remove jquery" work mentioned. |
@SylvainCorlay any update on your usage/requirement ? Phase 1 is pretty much done (link above) and wouldn't mind getting another pair of eyes on some changes: adumesny@40f7286 I'll be posting on slack https://gridstackjs.troolee.com the NPM files to gather some early feedback and testing as well. |
@adumesny I overlooked some of your code I would suggest that you open a WIP Pull Request so the code changes can be discussed there |
@RSWilli I started phase 2 which is to convert to typescript as well. Decided to try that as I was getting some uglify only errors on gridstack.min.js (ok if Include regular .js) for my webpack app... This is early as I have NOT compiled/tested the TS files yet (need to change build system) but didn't want to loose 4+ days of work! |
the issue I'm still having even in 1.0.0 is that when I'm bundling gridstack (using rollup), I get the Error:
which is at the GridStack.init Fn: GridStack.init = function(opts, elOrString) {
if (!elOrString) { elOrString = '.grid-stack' }
var el = $(elOrString).get(0); // <---- Error
if (!el) return;
if (!el.gridstack) {
el.gridstack = new GridStack(el, opts);
}
return el.gridstack
}; I would really like to help with removing jQuery, but I think I need to wait until you finished the TS conversion, or we'll get conflicts |
Thinking about a solution, I came up with the idea to modify the included Jquery file, so it would be an ES Module, that can be seamlessly bundled with gridstack This could be a solution for the transition period to completely removing it At the moment the window object still gets the $ from jQuery attached @adumesny what do you think? |
@adumesny I reviewed the commit adumesny@2d79abc I don't think that I got everything, but I wrote some comments |
@RSWilli in your app did you include I didn't have runtime issues in my webpack Angular app with it (only issue is I had to add Also I included gs in the module that uses it rather than on global scope If you have a suggestion on making an ES Module I'm all ear as I had to comment some of the imports - search for '[alain]' in 3 files as it didn't work in webpack vs browser include before. I want to hide the fact we use jq/jqui (bundle with code that needs it for now) while supporting those that do use jq to not have to include it again. If you want to work on my |
Hopefully the transitioning does not take a long time but it might be safer to also create a dist file that assumes |
@btecu dist/ folder contains all the parts. gridstack.all.js just happens to include all 5 files right now, The app can still use jquery/jqueryui from us, or import their own and include just the 2 gridstack js files. see https://github.com/gridstack/gridstack.js#migrating-to-v100 (jQuery Applications section) drag&drop using HTML5 custom code will be the hardest. |
@mikehaas763 absolutely! the For one thing the karma tests are not running anymore (I changed .js entry to use .ts files for code coverage as well) and wondering if that something you might be more familiar with. Also I'm using webpack to generate a single so yeah any help would be greatly appreciated! Using this ticket to track issues/progress. |
* copied over the latest bug fixes from develop. apparently I had missed some (row feature, etc..) * `addWidget(el, x, y, width, ...)` now obsolete but sitll supported warning * started 2.x readme section more gridstack#1084
* the karma test cases are now all working again (found some actual issues in new TS code) * most test changes are `let` vs `var` getSttribute() returning NULL instead of undefined and removing jquery calls * code coverage NOT working right now (need to figure how to test .ts files ?) * reverted karma.config.js for now (pre TS changes) more gridstack#1084
Do you know approximately when it will be finish (sorry can't help here, I am pretty new in migrating things like that) ? Good luck, and you are going great :) To know if I work on an other thing when waiting for the next release or if I use the script version ? Some people are using the npm version since release 1.0 ? For me it's totally broken with my build. |
a lot longer without help! and yes you can help by donating as well (hint) I'm doing this on my own spare time... my plan is to release a v2.0 typescript based version where all jquery code has been removed from
make sure you read the https://github.com/gridstack/gridstack.js#migrating-to-v100 and bottom section and file a bug if that doesn't work. |
* added a bunch of test cases to covert all methods (appart for events and drag&drop callbacks) * found couple issues in code while writting those tests! (what they are supposed to be for) * replaced all `var` with `let` part of gridstack#1084 next up: remove all jquery from main code
* only 10 $ instances left - mostly events drag&drop * converted couple jquery events callbacks to plain vanilla... more todo part of gridstack#1084
* all events are now handled by GridStack and no longer use jquery - changed the signature of some. * removed all $ jquery out of main code (engine, util and now gridstack.ts) * fixed `dragstop | resizestop` to be called *after* we update the node attributes no need for old `gsdragstop` - if you call `grid.on()` events rather than directly jquery events. part of gridstack#1084 still TODO: deeper testing to make sure I didn't break anything. Checking in wkd work now.
* gridstack.all.js is now min again and back to 185k (from 550k with sourcemap) * added @internal to prevent exporting private methods/vars to .d.ts * fixed test cases again * move jquery files to sub folder (what remains to convert) more gridstack#1084
BIG, BIG change for v1.0.0 release! * all calls/return take HTLMElement | string, not JQuery anymore * the `change|removed|added` events are now using standard calls with CustomEvent (rest are still JQ based) but all share basic same callback signature still. * added `grid.on(eventName, callback)` / `grid.off(eventName)` to hide native JQ events mix * updated all demos+doc to only plain DOM manipulation (only custom drag&drop jq UI remain) * created how to upgrade to 1.0.0 section * part of gridstack#1084 **Note**: had to modify jquery and jquery-ui loading (look for [alain] comment) to be able to compile it in and still work with webpack. Also (API break) * `setColumn(N)` is now `column(N)` and new `getColumn()` (matches other set/get methods) RANT: I hate git... must have wasted half day doing a rebase from develop on jquery branch only to scrap that and start over with latest and dumping my changes.
is there any beta version without the jQuery dependency out yet? |
@capc0 no, 2.0 isn't out yet but I'm still working on the typescript branch (what is 2.x) with a bunch of fixes as well - not working on main branch anymore as I want to switch now. I need to get back to packaging issues to publish it but could really use some help there... |
Hello @adumesny, I know it's hard to predict a date, but can this version without JQuery take a long time yet? Thanks for your work! |
@jaderson-araujo I haven't seen your contribution to this project (time/code or $ - there is a donation button in case you missed it) - this has been an enormous amount of work (many times over the original owner contributions) and yet people expect it to just be done... |
@adumesny btw, I take this occasion to say how grateful we are for your work on gridstack. |
@SylvainCorlay good to hear you are still hanging around as you started this thread... but still waiting on that help :) |
very happy to say this is finally done with release of v3.0.0 - yeah! |
Hello, thanks for this great project! I have used it for a couple of projects and it has been working really well.
I am curious on whether there had been discussions in the core team on dropping JQuery altogether in the gridstackJS project? I presume that a lot could be done with native DOM APIs now...
The text was updated successfully, but these errors were encountered: