Sync require of node module doesn't work without loading it as a dependency
bryanforbes opened this issue · 0 comments
bryanforbes commented
Currently, the following code does not work:
define([ 'require' ], function (require) {
var events = require('events');
});
However, the following does:
define([ 'require', 'events' ], function (require) {
var events = require('events');
});
It seems that the fallback to node packages is only happening if the module ID appears in the array passed to define
or require
. This is a bit strange (in my mind) since the node modules are available for use, but need to be loaded into the loader before use. To me, either of the above bits of code should work. For reference, the behavior I'm describing is the behavior of RequireJS.