Elad Katz
Elad Katz

Reputation: 7601

system.js import from another folder

I have public/index.html and src/app.js.

Inside index.html i have the following system.js call to load app.js

<script>System.import('../src/app');</script>

It fails with the following error:

GET https://registry.jspm.io/src/app.js 404 (Not Found)

What should be the syntax to load files from another folder?

Upvotes: 4

Views: 6319

Answers (1)

John Abraham
John Abraham

Reputation: 18831

You may have forgotten a few other things:

1) you must import system.js (auto installed with jspm init)

2) you must include your config.js (auto installed with jspm init)

        <script src="../jspm_packages/system.js"></script>

        <script src="../config.js"></script>

        <script>
            System.import('client/index').catch(console.log.bind(console));
        </script>

3) see how my import says 'client/index' it means my folder structure looks like this:

enter image description here

4) Now lastly the config.js has base path (this is from where your system.import will start; regardless of where the index.html file is.)

System.config({
  "baseURL": "/",
  "transpiler": "traceur",
  "paths": {
    "*": "*.js",
    "github:*": "jspm_packages/github/*.js",
    "npm:*": "jspm_packages/npm/*.js"
  }
});

one of these should fix everything. I think it's #2

Upvotes: 2

Related Questions