-
-
Save Tug/7987337 to your computer and use it in GitHub Desktop.
`a.js` is called before `b.js`. (There is some asynchronous stuff going one between the 2 calls).
Here Visit is going to be undefined when required in `b.js`, no error thrown.
If I call `require_public('models/Visit')` at position 1, it works fine. Even in `b.js`, Visit will be defined (probably because it's kept in memory once loaded).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modules.exports = function (app) { | |
var requirejs = require("requirejs"); | |
var path = require("path"); | |
requirejs.config({ | |
baseUrl: path.join(app.config.paths.root, "public/js") | |
}); | |
app.require_public = requirejs; | |
// position 1 | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modules.exports = function (app) { | |
// position 2 | |
var Visit = app.require_public('models/Visit'); | |
console.log("Visit", Visit); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment