dropchop
dropchop copied to clipboard
Simplify browserify bundles with `require` module
I started work over the weekend to require
modules within the dropchop source. This would be one of the first steps in removing the dependency on Gulp as we could run browserify as a npm
one-liner rather than streaming each module through Gulp.
Nice! I started taking a peak at the lift this is going to be .. it's more complex than I hoped, considering everything is written in the dc = dc || {}
syntax. Some thoughts around how to initialize each *.dropchop.js
's init()
function and continue using $(dc).on
and $(dc).trigger
as the publication/subscription model would be 👍
Speculating here with some pseudocode. Maybe make each piece modular like
module.exports = function() {
...
return someInitFunction
}
Then in dropchop.js
var map = require('./dropchop.map')
...
dc.map = map()
...
Appreciate input from anyone.
@mapsam Is this a hard block on #261 or does it not affect modularization?
@wboykinm I don't think so. You could probably add each of the turf modules to this array instead of the main turf library. It's worth a try since this issue might take a while.
Indeed - @nickpeihl's array idea should work just fine for now.
@mapsam: Do you have any references or links to the type of architecture design used in dropchop? I'm not familiar with this style of application architecture.
@nickpeihl all of dropchop is currently written in the "module pattern" (not to be confused with npm modules) and I always find this article super helpful in how to organize code, globals, and share across files: http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
Introducing require
and browserify may or may not require us to re-architect how dropchop is written.