I have all these modules that are declared in this fashion based on a Global app
variable which is then bundled via gulpfile
view1.js
var app = app || {}
app.View1 = Backbone.View.extend({});
view2.js
var app = app || {}
app.View1 = Backbone.View.extend({});
So I reference between the files using:
var app = app || {};
new app.View1();
new app.View2();
At this point this approach is obsolete.
Using babel
infact I would like to compile with browserify
using new fashion module exports
view1.js
import Backbone
export default = Backbone.View.extend({});
Now, my problem is that I would like to start migrating without editing the old modules ( at least for now ). I tried something like that:
import * as _ from "underscore";
import Backbone from "Backbone";
import * as LoginModal from "../views/loginModal";
import Router from "./router";
new LoginModal();
new Router();
Backbone.history.start({
pushState : true,
hashChange : false
});
The problem is that in LoginModal
various globals as _
or $
are undefined.
Any idea on how to keep both types of modules and bundle them together?