Could you provide more details so we can better understand you scenario?
Where AMD loader is not available, the library should fall-back to CommonJS.
Something like this (or switch to a cross-compatible format like UMD)
Thank you, I'll look into this in the next sprint.
Any updates here?
@kamilszostak ? :)
I apologize for the delay. I'll do my best to look into this item next week.
I took a closer look at CommonJS support. TypeScript compiler allows to choose a module loading standards: AMD or CommonJS (see -module in tsc options doc).
Unfortunately, for CommonJS it doesn't support combining external modules and it's not possible to merge all output *.js files into one file.
Could you explain your scenario a bit better? If your code is running on a server side, it might be OK if JS SDK files are not combined. If your code is running in the browser, AMD seems like a better choice.
@kamilszostak
The main idea is to support es6 modules (import/export). An added advantage is that this library does not pollute to global scope when using a module loader (like webpack or systemjs).
You can wrap the dist code inside an umd wrapper.(https://github.com/umdjs/umd/blob/master/templates/returnExports.js#L41)
Thereby supporting both commonJs, AMD and window.
If you use the provided snippet do not forget to change root.returnExports to root.Microsoft.
Any update on this?
This Babel plugin can be useful as a workaround: babel-plugin-transform-amd-to-commonjs.
v2 sdk uses es6 modules for npm consumption and umd modules for CDN consumption. This should hopefully resolve all compatibility issues for now!
https://www.npmjs.com/package/@microsoft/applicationinsights-web#getting-started
Cool, thanks @markwolff, I'll try it.
So @microsoft/applicationinsights-web is the v2 of applicationinsights-js? Is there a changelog to help users with the upgrade?
@pviotti Correct, that is the v2 version. There is no changelog yet since it is still in a beta stage, but it is meant to keep the same overall functionality as v1. Most of the differences are at the API layer, e.g arguments were switched to objects instead of positional ones. Since typings are included, intellisense should help with that. If you do run into issues, please do let me know!
@markwolff Is there a roadmap for v2? Expected "gold" date? Trying to plan a new implementation of AppInsights and don't want to use the old one just to be replaced soon
@tommck Most likely January
Most helpful comment
@kamilszostak
The main idea is to support es6 modules (import/export). An added advantage is that this library does not pollute to global scope when using a module loader (like webpack or systemjs).
You can wrap the dist code inside an umd wrapper.(https://github.com/umdjs/umd/blob/master/templates/returnExports.js#L41)
Thereby supporting both commonJs, AMD and window.
If you use the provided snippet do not forget to change root.returnExports to root.Microsoft.