Skip to content

Moving forward with ES6 modules (or commonjs) #603

Closed
@0cv

Description

@0cv

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:

const jQuery = require('jquery')

//minimal required jquery-ui modules 
require('jquery-ui/core')
require('jquery-ui/widget')
require('jquery-ui/effect-blind')

//import of fancytree by injecting jquery
require('imports?jQuery=jquery!jquery.fancytree/dist/jquery.fancytree.js')

//potential extensions (by injecting jquery as well)
require('imports?jQuery=jquery!jquery.fancytree/src/jquery.fancytree.childcounter.js')

//from here we can now use jQuery#fancytree

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:

var jQuery = require('jquery');
(function( $, undefined ) {
  //...
})( jQuery );

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions