jspm / registry

The jspm registry and package.json override service
https://jspm.io
230 stars 255 forks source link

How to use two versions of a package, one from a script tag? #832

Open frankandrobot opened 8 years ago

frankandrobot commented 8 years ago

I'm supporting a legacy app that imports one version of angular via script tags. They've added JSPM/SystemJS support to load JSPM components. However, the components use a different version of angular and don't assume a global angular. However, the two versions of angular collide with "tried to load angular more than once" warning. This issue is related to https://github.com/jspm/registry/issues/831 The code is below:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>title</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.29/angular.js"></script>
    <script src="jspm_packages/system.js"></script>
    <script src="config.js"></script>
    <script>
        console.log(angular.version) // 1.2.29

        System.config({
            meta: {
                'github:angular/bower-angular@1.5.2/angular.js': {
                    exports: 'angular'
                }
            }
        })

        System.import('angular') // doesn't load 1.5.2. Gives warning
    </script>
</head>
<body>
</body>
</html>
guybedford commented 8 years ago

Since angular is going to detect collission and fail in that case, you probably just want to ensure you're using one version of angular here.