-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Moving forward with ES6 modules (or commonjs) #603
Comments
Thanks, I am open to improvements here. |
Backwards compatibility is possible when checking whether a module wrapper exists. Here is a good blog post about it http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/ Now, I see an additional complexity in regards to what to load from jquery-ui. OOTB, the 3 jquery-ui modules I've listed above are enough (even so they load more by themselves), but I think that this plugin supports more than just the "blind" effect... Apart from this, some assumptions could be done for simplifying. People downloading the dist file are for sure not interested in any module bundling and will put straight the minified file in a script tag. Others using browserify may not be interested either in module bundling while those using npm are very likely the ones who are interested in that. It looks like that's the approach that the folks at jquery-ui have been using (by putting straight |
It is too bad that we can't include this lib easily via NPM in a process build via Brunch for instance. |
It seems that jQuery UI 1.12 has changed the widget layout. Any suggestions anyone? |
IMO , fancytree is a nice plugin and it should be refactored to get rid of jquery UI widget system and could be easily a modular to support UMD. |
is there any requirejs solution yet ? |
Currently there is very little documentation to show how to work with requirejs with latest version. Here is how made it work with requirejs.config({
paths: {
'jquery': './js/vendor/jquery',
'jquery-ui': './js/vendor/jquery-ui',
'jquery.fancytree': './js/vendor/fancytree/jquery.fancytree-all'
},
shim: {
'jquery.fancytree': {
deps: ['jquery', 'jquery-ui/core', 'jquery-ui/effect', 'jquery-ui/effects/effect-blind', 'jquery-ui/widgets/draggable', 'jquery-ui/widgets/droppable'],
exports: 'jQuery.fn.fancytree'
}
},
onBuildWrite: function (moduleName, path, contents) {
'use strict';
if (moduleName === 'jquery.fancytree') {
contents = 'define( "jquery.fancytree", ["jquery", "jquery-ui/core", "jquery-ui/effect", "jquery-ui/effects/effect-blind", "jquery-ui/widgets/draggable", "jquery-ui/widgets/droppable"], function(jQuery) { ' + contents + '});';
}
return contents;
}
});
// usage
define([
'jquery',
'jquery.fancytree',
'css!./css/fancytree/skin-custom/ui.fancytree.css',
],
function($) {
'use strict';
//
$('#tree').fancytree({
checkbox: true,
source: [{title: 'Node 1'}, {title: 'Node 2',key: 'id2'}]
});
//
});
// |
@djangosdk Thanks for giving an example. |
See https://github.com/mar10/fancytree/wiki#embed-fancytree-on-your-web-page for new module support |
Most web projects are now using modules bundler (such as Webpack, System.js, JSPM, etc.) for building assets. This would be good to make the use of Fancytree easier with these bundlers. This is how I managed to use Fancytree (in the most simple way) with Webpack, which feels quite awkward, even so it works:
While jQuery does not play very well with any module bundler, an easy improvement idea would be to do something similar to jqueryUi, by requiring jquery automatically, instead of assuming jQuery as a global variable.
E.g. jquery-ui/core.js looks like that:
The text was updated successfully, but these errors were encountered: