Skip to content
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

Simplify browserify bundles with require module #263

Open
nickpeihl opened this issue Aug 1, 2016 · 7 comments
Open

Simplify browserify bundles with require module #263

nickpeihl opened this issue Aug 1, 2016 · 7 comments

Comments

@nickpeihl
Copy link
Member

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.

@mapsam
Copy link
Member

mapsam commented Aug 1, 2016

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 👍

@nickpeihl
Copy link
Member Author

nickpeihl commented Aug 1, 2016

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.

@wboykinm
Copy link

wboykinm commented Aug 2, 2016

@mapsam Is this a hard block on #261 or does it not affect modularization?

@nickpeihl
Copy link
Member Author

@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.

@mapsam
Copy link
Member

mapsam commented Aug 2, 2016

Indeed - @nickpeihl's array idea should work just fine for now.

@nickpeihl
Copy link
Member Author

@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.

@mapsam
Copy link
Member

mapsam commented Aug 3, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants