I’ve got a problem with goJS module not somehow getting its declaration working in an Angular2 app when it is loaded in Electron. What is weird is that it loads, and resolves definitions fine when I run the exact html/js code as a simple website.
my local.component.ts code has a simple:
require('go');
declare var go:any;
... ...
... ...
var newDiagram = go.Model.fromJson(modelData);
here’s the bit of code to access that module in my webpack.config –
module: {
loaders: [
// Only apply on gojs/release/go-debug.js
{include: require.resolve('gojs/release/go.js'), loader: 'exports?go'},
... ....
resolve: {
alias: {
// require('go') will do require('gojs/release/go-debug.js')
go: 'gojs/release/go.js'
},
I’ve been beating my head against a wall for 3 days trying to understand why “go” resolves and works when I load it off of localhost:3000
, but inside the electron app the module.export = go
is failing because it says 'go is undefined'
.
I’ve tried everything from using a script tag include in the HTML (index) directly, to including the module at the main app module file, to putting it in the local component I need it in… same result in each case-- it works to resolve the definition when I load the page in regular browser… but fails when I try to run it inside electron.
I’ve looked at the one sample included in the GoJS samples directory that talks about electron. It is using a script src=
tag to pull in goJS… I tried that method too… again, it works when I do that to launch it as a website (ie. localhost:3000
) but fails when I load it in electron.