Hi Walter,
I am not loading go.js using a script tag because I am using requirejs to load the module.
I am importing go using the following code and it does work in development.
require(["go"], function(go) {
console.log(go);
var $ = go.GraphObject.make;
});
However if I also change my code to the following it still works:
require(["go"], function(thisIsNotTheGoJsLib) {
console.log(go);
var $ = go.GraphObject.make;
});
Which indicates to me that “go” is declared globally because the go module imported (thisIsNotTheGoJsLib) is not being used and “go” is not declared anywhere else.
I am not an expert with requirejs, but my guess is that when the optimization is done it it imports the gojs lib globally, but then excludes the lib from the requirejs import, because it already exists.
This means that after optimization the imported “go” is not defined hence the error. (however i’m not really sure why it is not using the global version as it seems to do in development, other than the optimization prevents this.)
Can I ask that you look at your sample code “require.html”
This is the original code with the addition of the console.log:
This code works. Now change the code to this:
This still works, but the imported lib var has been changed to “goLib” and the code is still referencing the var “go”. Where is “go” defined?
Now change the code to this
Now “go” is not defined
So by importing the code using requireJs it is making go available globally, but also assigning it to “goLib”
If it makes it easier, I am happy to arrange a skype call to go through the problem.