I am using RequireJS with order.js
and I need to use xregexp-all
to include in RequireJS. Here is my code sample:
require(["order!xregexp-all","order!../myscript"],function(XRegExp) {console.log(XRegExp.version)});
Here is the console log that returns me the version. But I could not able to use the XregExp in myscript.js
it gives me following Error:
"XRegExp is not defined"
How can I use XRegExp in the rest of the code?
the second argument of require is a function, with a parameter, that you named XRegExp. Outside this context it does not exist. What you can do is create a global variable, and assign it in that context to the XRegExp:
var myRegExp;
require(["order!xregexp-all","order!../myscript"],function(XRegExp) {
myRegExp = XRegExp;
console.log(XRegExp.version)
});
//... rest of your coude...//
console.log(myRegExp);