4

I ran jspm install angular and it installed it locally to my jspm_packages folder.

From code, I use regular ES6 imports like import angular from 'angular'.

What do I need to do in order to load angular from a CDN and fallback to a local version if the CDN is unavailable?

Natan
  • 4,686
  • 5
  • 30
  • 48
  • I don't think it's possible, at least not without doing it yourself somehow (effectively replacing SystemJS) – Amit Jul 21 '15 at 20:16

2 Answers2

8

You can have different config.js files for development and production, where the production one gets angular from a CDN while development gets it locally. However, there is not (as far as I know) currently a way to have SystemJS try one source, then if that fails fallback to another source.

System.config({
    "map": {
        "jquery": "https://code.jquery.com/jquery-2.1.4.js"
    }
});
Micah Zoltu
  • 6,764
  • 5
  • 44
  • 72
0

I would you suggest to create an adapter module for angular:

local-repo/angular.js

define(function() {
    return window.angular;
});

Like this you can use your config file for deployment and production. In production you simply make sure that you load angular first:

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.min.js"></script> systemjs code..

Spidi
  • 138
  • 2
  • 5