I have a legacy JS file, written in the following RequireJS (AMD) module notation:
define('mymodule', [], function(){
// ... bla bla bla
return {
calculate: function() { return 1 + 1; }
};
});
I'm importing this file from another (legacy) project that uses RequireJS, therefore - I can't change the module definition used.
I want to import it in an Angular Cli (Angular 4.x) app written in TypeScript.
Since Angular Cli uses Webpack 2 to build projects, which supports AMD, I thought I can import it like this:
import * as MyModule from './mymodule.js';
... but that's not working, it triggers an error that the mymodule.js
is not a module.
Any ideas (or workarounds) how can I import this legacy module?
I am able to load amd module.
here is TS:
mymodule.js file:
and in tsconfig.js
UPDATE:
You can use System.import provided by webpack.