Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CommonJS #301

Closed
ramijarrar opened this issue Aug 31, 2016 · 16 comments
Closed

Support CommonJS #301

ramijarrar opened this issue Aug 31, 2016 · 16 comments
Milestone

Comments

@ramijarrar
Copy link

No description provided.

@ramijarrar ramijarrar changed the title Support CommonJS/ES2015 import Support CommonJS Aug 31, 2016
@KamilSzostak
Copy link
Contributor

Could you provide more details so we can better understand you scenario?

@ramijarrar
Copy link
Author

ramijarrar commented Sep 1, 2016

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)

@KamilSzostak
Copy link
Contributor

Thank you, I'll look into this in the next sprint.

@ramijarrar
Copy link
Author

Any updates here?

@dbpieter
Copy link

dbpieter commented Jan 5, 2017

@KamilSzostak ? :)

@KamilSzostak
Copy link
Contributor

KamilSzostak commented Jan 5, 2017

I apologize for the delay. I'll do my best to look into this item next week.

@KamilSzostak
Copy link
Contributor

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.

@dbpieter
Copy link

@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.

@Fredkr
Copy link

Fredkr commented Sep 28, 2018

Any update on this?

@pviotti
Copy link

pviotti commented Oct 24, 2018

This Babel plugin can be useful as a workaround: babel-plugin-transform-amd-to-commonjs.

@markwolff
Copy link
Contributor

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

@pviotti
Copy link

pviotti commented Nov 28, 2018

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?

@markwolff
Copy link
Contributor

@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!

@tommck
Copy link

tommck commented Dec 14, 2018

@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

@markwolff
Copy link
Contributor

@tommck Most likely January

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants