jspm / registry

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

Bootstrap overrides appear incorrect? #1037

Open dougludlow opened 7 years ago

dougludlow commented 7 years ago

I've been trying to get bootstrap to work with JSPM, but keep running into issues. I started a new project and went through the following steps:

$ yarn global add jspm@beta
$ jspm init # chose defaults on all except named the main file app.ts
$ jspm install bootstrap@3.3.7
$ touch src/app.ts
$ touch index.html

Add the following to src/app.ts:

import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.css!'

Add the following to index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Bootstrap Test</title>
</head>
<body>
    <div class="container">
      <div class="jumbotron">
        <h1>Hello world!</h1>
      </div>
    </div> 

    <script src="jspm_packages/system.js"></script>
    <script src="jspm.config.js"></script>
    <script>
        System.import('app');
    </script>
</body>
</html>

When I serve that up, I see the following error:

Error: Fetch error: 404 Not Found
  Instantiating http://127.0.0.1:8080/jspm_packages/github/twbs/bootstrap@3.3.7/js/bootstrap.js
  Loading http://127.0.0.1:8080/src/app.ts
  Loading app  
system.js:4

When I take a look at the override for bootstrap@3.3.7, I see this:

    "main": "js/bootstrap.js",

Looking in the bootstrap github repo (https://github.com/twbs/bootstrap/tree/v3.3.7/js), there is no js/bootstrap.js. This should be dist/js/bootstrap.js.

Downgrading to bootstrap@3.3.6 appears to work fine. I'm assuming that is due to the systemjs property in the override which points to the correct main (dist/js/bootstrap.js).

Interestingly enough, when upgrading back to bootstrap@3.3.7, it works, but this is because my package.json has kept the 3.3.6 overrides for some reason:

...
      "github:twbs/bootstrap@3.3.7": {
        "shim": {
          "js/bootstrap": {
            "deps": [
              "jquery"
            ],
            "exports": "$"
          }
        },
        "dependencies": {
          "jquery": "2"
        },
        "files": [
          "dist",
          "fonts",
          "js",
          "css",
          "less",
          "grunt",
          "LICENSE"
        ],
        "systemjs": {
          "main": "dist/js/bootstrap.js",
          "modules": {
            "dist/js/bootstrap.js": {
              "deps": [
                "jquery"
              ],
              "exports": "$"
            }
          }
        }
      },
...

jspm version: 0.17.0-beta.40 systemjs version: SystemJS v0.20.9 Dev (bundles with jspm)