I have an angular 2 application and am using ng2-dragula library. Everything is working in development (JIT compilation) mode. When I compile with AOT, the aot build and rollup are successful, but then I get this error in the browser:
Uncaught ReferenceError: require is not defined
at dragula.js:3
at main-aot.js:6
This error comes from these lines at the top of dragula.js file.
var emitter = require('contra/emitter');
var crossvent = require('crossvent');
var classes = require('./classes');
I tried adding requirejs to my project, and then I got this error:
Uncaught Error: Module name "contra/emitter" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
So I went to the require page "common errors" and tried following some of their suggestions and then got this error between two non-dragula related scripts
Mismatched anonymous define() module: blah blah
but these work fine by themselves in AOT when require.js isnt added to the project.
Is there a way to modify those require statements to make this work in AOT? Why am I not getting this error in JIT compilation? Pretty stuck here.