Unfortunately, with Angular there appear to be a lot of config files and base files required to make a project run. Rather than littering this page with code and making a big copy paste job, I have put it in a repo that can be cloned and run here. Or it can be run online in using StackBlitz here. StackBlitz also cannot resolve the "TFS" package that should be being included from the VSS Web Extension Package.
I am trying to use the VSS Web Extension SDK and Angular together in order to make a custom widget for my Azure Dashboard. (Please note that access to Azure is not required for this question)
I am unable to load the library I want to use at runtime and I am unsure of why.
I am getting the following error.
Uncaught ReferenceError: TFS is not defined
at Object.TFS/Dashboards/WidgetHelpers (WidgetHelpers":1)
at __webpack_require__ (bootstrap:79)
at Object../src/app/app.component.ts (Binding.component.ts:14)
at __webpack_require__ (bootstrap:79)
at Object../src/app/app.module.ts (app.component.ts:76)
at __webpack_require__ (bootstrap:79)
at Object../src/main.ts (environment.ts:19)
at __webpack_require__ (bootstrap:79)
at Object.0 (polyfills.ts:72)
at __webpack_require__ (bootstrap:79)
I have a custom webpack config file to extend the default angular build webpack config that looks like
module.exports = {
externals: [
/^VSS\/.*/, /^TFS\/.*/, /^q$/
]
};
The externals were extracted from a project that seemed to have a webpack config file set up, called Generator VSTS Extension. Their config can be accessed here. I found this after I was having build issues at compile time.
The error is generated at run time from the app.component.ts
file. When the lines that involve the library are commented out, there are no issues.
I'm quite new to both Webpack and Angular so I've probably made a mistake with extending the Angular builder but I am not sure. Does anyone have any suggestions on what I am doing wrong?
I have uploaded a minimal runnable example project to GitHub that can be downloaded and run as long as you have npm set up. You can get that here. Run with StackBlitz