-1

I do not understand very well systemjs I am having problems when trying to import by angular

It works well

Import {UtilClass} from './shared/util.class';

I have a component in another folder but if I try to load it

Import {UtilClass} from '../shared/util.class';

I have the following error and verifying in the log loaded files what I observe is that it is not putting the extension js when I use "../" / util.class 404 (Not Found)

(function (global) {

var staticPath='src/';

var paths = {
    // paths serve as alias
    'npm:': 'https://unpkg.com/'
};

// map tells the System loader where to look for things
var map = {
    'app': 'app',
    // angular bundles
    '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
    '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
    '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
    '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
    '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
    '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
    '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
    '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
    '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
    '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
    '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
    '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

    // other libraries
    'rxjs': 'npm:rxjs@5.0.1',
    'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
    'ts': 'npm:plugin-typescript@5.2.7/lib/plugin.js',
    'typescript': 'npm:typescript@2.2.1/lib/typescript.js',
};

// packages tells the System loader how to load when no filename and/or no extension
var packages = {

    'app': {
        main: '../..' + staticPath + '/main',
        defaultExtension: 'js',
        defaultJSExtensions: true
    }
    ,
    'rxjs': {
        defaultExtension: 'js'
    }
};

var config = {
    map: map,
    packages: packages,
    paths: paths
};

System.config(config);
})(this);
Roman C
  • 49,761
  • 33
  • 66
  • 176
Hector Bayona
  • 97
  • 1
  • 2
  • 6

1 Answers1

0

When the route is relative this error occurs I suppose there is a better way to correct it.

var packages = {
'app': {
    main: '../..' + staticPath + '/main',
    defaultExtension: 'js',
    defaultJSExtensions: true
}
,
'rxjs': {
    defaultExtension: 'js'
}
};
//I added this and works
packages['./../..'+staticPath+'/']={main:'main',defaultExtension: 'js'}
Hector Bayona
  • 97
  • 1
  • 2
  • 6