JIT compiling angular2 works and runs fine with importing the namespace like this:
import * as go from 'gojs';
and loading the go-debug.js file via the system.js module loader. I have no issues typescript compiling the app, the issue is with AOT compiling the angular app and the subsequent rollup. When you move an angular2 app into production you want to AOT (Ahead Of Time) compile it. The difference is waiting to load 100’s (possibly 1000s in larger Angular2 apps) before angular bootstraps, or 1. In order to get all your typescript files into js files and then mushed into 1 js file, angular recommends using some plugins.
The plugin that is failing to execute is called rollup-plugin-uglify. So once all rollup preforms a treeshake, and removes all un-referenced modules, it tries to execute the rollup-plugin-uglify.uglify plugin that basically minimizes the generated js (remove whitespace and make all js variables singe letter, etc), so it makes your single js file tiny. That step is failing when i started to refernce the gojs namespace.
I can probably look at using over tools to minimize the outputted AOT generated js file, but If other devs follow the angular2 quickstart and try to AOT their apps per Angular2’s recommendations they will probably get this error as well.
To get past this in the short term i commented out the call to uglify() function in my rollup-config.js file.
import rollup from 'rollup';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'app/main-aot.js',
dest: 'app/dist/build.js', // output a single application bundle
sourceMap: true,
sourceMapFile: 'app/dist/build.js.map',
treeshake: true,
format: 'iife',
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: [
'node_modules/rxjs/**',
'node_modules/gojs/**'
]
})
//, uglify()
]
}
But this means that my outputted AOT compiled file is ~2700Kb vs ~270Kb it was before gojs and after uglfification.