Import system.js from another folder

I have public/index.html

and src/app.js

.

Inside index.html

I have the following call system.js

to loadapp.js

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

The following error failed:

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

What should be the syntax for loading files from another folder?

+3


source to share


1 answer


You may have forgotten a few more things:

1) you should import system.js (automatically installed with jspm init)

2) you have to specify config.js

yours (automatically 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) look at how my import says "client / index", it means my folder structure looks like this:



enter image description here

4) Now the latter config.js

has a base path (this is where your system.import will run, no matter 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 them is to fix everything. I think this is # 2

+2


source







All Articles