admin管理员组

文章数量:1410724

Hello I have the following config set up for systemJS:

    System.config({
    packages: {
        //sets the root path of the Angular2 App
        'DesktopModules/RegentDMS/app': {
            //module format expected in application, register = System.register or System.registerDynamic patibility module format
            format: 'register',
            //default file extension for paths
            defaultExtension: 'js',
            map: {'./app' : './DesktopModules/RegentDMS/app'}
        },
    } 
  }); 
System.import('app/boot')
        .then(null, console.error.bind(console));

The default extension works fine but I get is a 404 error in the console that says:

GET http://localhost:81/app/boot 404 (Not Found)

But if I change it to the following:

    System.config({
    packages: {
        //sets the root path of the Angular2 App
        'DesktopModules/RegentDMS/app': {
            //module format expected in application, register = System.register or System.registerDynamic patibility module format
            format: 'register',
            //default file extension for paths
            defaultExtension: 'js'
        },
    } 
  }); 
System.import('/DesktopModules/RegentDMS/app/boot.js')
        .then(null, console.error.bind(console));

Then it does work.

QUESTION:

how can I set up the MAP setting so that I can use the short hand app/ to refer to the absolute path of DesktopModules/RegentDMS/app in import statements like app/boot (meaning DesktopModules/RegentDMS/app/boot.js)

Thanks

EDIT #1:

So i changed the ./app to app as suggested and tried both of the following:

 map: { 'app': './DesktopModules/RegentDMS/app' }
 map: { app: './DesktopModules/RegentDMS/app' }

and this does not work when using any of the following import statements:

System.import('app/boot')
 System.import('./app/boot')

I get the following error for both:

http://localhost:81/app/boot 404 (Not Found)

SOLUTION:

Move the map declaration to the config object like so:

    System.config({
    packages: {
        //sets the root path of the Angular2 App
        'DesktopModules/RegentDMS/app': {
            //module format expected in application, register = System.register or System.registerDynamic patibility module format
            format: 'register',
            //default file extension for paths
            defaultExtension: 'js'
        }
    },
    map: { 'app': './DesktopModules/RegentDMS/app' }
  }); 
System.import('app/boot')
        .then(null, console.error.bind(console));

Hello I have the following config set up for systemJS:

    System.config({
    packages: {
        //sets the root path of the Angular2 App
        'DesktopModules/RegentDMS/app': {
            //module format expected in application, register = System.register or System.registerDynamic patibility module format
            format: 'register',
            //default file extension for paths
            defaultExtension: 'js',
            map: {'./app' : './DesktopModules/RegentDMS/app'}
        },
    } 
  }); 
System.import('app/boot')
        .then(null, console.error.bind(console));

The default extension works fine but I get is a 404 error in the console that says:

GET http://localhost:81/app/boot 404 (Not Found)

But if I change it to the following:

    System.config({
    packages: {
        //sets the root path of the Angular2 App
        'DesktopModules/RegentDMS/app': {
            //module format expected in application, register = System.register or System.registerDynamic patibility module format
            format: 'register',
            //default file extension for paths
            defaultExtension: 'js'
        },
    } 
  }); 
System.import('/DesktopModules/RegentDMS/app/boot.js')
        .then(null, console.error.bind(console));

Then it does work.

QUESTION:

how can I set up the MAP setting so that I can use the short hand app/ to refer to the absolute path of DesktopModules/RegentDMS/app in import statements like app/boot (meaning DesktopModules/RegentDMS/app/boot.js)

Thanks

EDIT #1:

So i changed the ./app to app as suggested and tried both of the following:

 map: { 'app': './DesktopModules/RegentDMS/app' }
 map: { app: './DesktopModules/RegentDMS/app' }

and this does not work when using any of the following import statements:

System.import('app/boot')
 System.import('./app/boot')

I get the following error for both:

http://localhost:81/app/boot 404 (Not Found)

SOLUTION:

Move the map declaration to the config object like so:

    System.config({
    packages: {
        //sets the root path of the Angular2 App
        'DesktopModules/RegentDMS/app': {
            //module format expected in application, register = System.register or System.registerDynamic patibility module format
            format: 'register',
            //default file extension for paths
            defaultExtension: 'js'
        }
    },
    map: { 'app': './DesktopModules/RegentDMS/app' }
  }); 
System.import('app/boot')
        .then(null, console.error.bind(console));
Share Improve this question edited Jan 17, 2016 at 0:02 J King asked Jan 16, 2016 at 19:32 J KingJ King 4,44410 gold badges61 silver badges116 bronze badges 1
  • does not work, edited answer for more details – J King Commented Jan 16, 2016 at 23:47
Add a ment  | 

1 Answer 1

Reset to default 5

As @Langley suggested in ment, you should use app, not ./app (name not path), and move map definitions from packages object to the config object.

The map option ... allows you to map a module alias to a location or package:

https://github./systemjs/systemjs/blob/master/docs/config-api.md#map

本文标签: javascriptcan not get MAP to work within systemconfig packages for SystemJSStack Overflow