2

I'm wondering how you import components hosted somewhere else, like a CDN.

If I got a link to someone's CDN for example: <script src="a-cdn-link.js"></script> where a component named MyComponent resides, in my own component file, what would I use as the import path?

I know that you can use the framework itself if included via a CDN but I don't understand how they make it so that you fetch from the correct path. I haven't tried using the CDN to import angular2 so I'm not quite sure exactly how it works.

Would you have to declare a path via SystemJS or another similar service?

Could do with some enlightment on the matter.

Chrillewoodz
  • 27,055
  • 21
  • 92
  • 175

1 Answers1

1

In fact, you can include JS files like this if they use System.register('module-name', ... to register explicitly a named module. JS files like that are generally generated from TypeScript ones leveraging the outFile option of the TypeScript compiler.

If your JS files correspond to anonymous System modules or CommonJS / AMD ones, you need to configure them within the SystemJS configuration.

The following question could give some additional hints:

Community
  • 1
  • 1
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • So on the server side of things, you have to register the modules in SystemJS too? I'm not really familiar with SystemJS at all so what you just wrote doesn't make a whole lot of sense hehe. – Chrillewoodz Jun 11 '16 at 19:18