You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature request: strict mode for synchronous require() calls #51
define(["require"], function(require) { var x = require("X"); x.doSomething(); ...})
is valid and works if the module "X" is already loaded by the time this executes. That said, this is fragile code - nothing here guarantees that "X" is already loaded. It would be really useful if we could ban such code, e.g. via a config flag such that the local require() function would throw if the module did not declare the passed in string as a dep. That is, the code sample would instead be required to look like
define(["require", "X"], function(require) { var x = require("X"); x.doSomething(); ...})
I don't think the same change can be easily made to the global require() & requirejs() functions, but it's possible to ban usage of those in a codebase via types, convention, lint, or other static analysis that specifically looks for global variable usage.
Activity