How to add webpack externals without running eject in ng CLI?

Viewed 376

quick question on the Angular CLI.

Usually when I'm using webpack, I'm able to register externals within the webpack config (https://webpack.js.org/configuration/externals/) for any objects that are saved to the window object. So, if I've got window.foo = bar, I can register that as an external with a name in my webpack.config.js, and then i can

var x = require("foo"); (or import * as foo from 'foo'; in typescript)

wherever I need it.

The problem is that the Angular CLI keeps the webpack config under a black box, and I REALLY don't want to eject from that.

For the full problem I'm experiencing, I need to take this library https://github.com/AzureAD/microsoft-authentication-library-for-js and use it in my Angular Typescript project. I'd like to be able to "import * as MSAL from 'msal';", but if you look into the source code for that library, it doesn't actually export it as a module, it just saves it to the window object.

Thanks!

0 Answers
Related