0

When I load the app from the root directory of my server the app works. This is not possible in practice because of the pretty urls our application uses. For example http://www.website.com/modules/worker/person/1/1/1 loading a page with the previous url results in system.js looking in the folder /modules/worker/person/1/1 rather than a folder based on "/".

The solution is to set baseURL:"/" such that the modules are loaded based on the root directory.

The problem with THIS solution is that node modules are not loaded properly, instead of looking in the node_modules directory, system.js is looking in the root. system.js looks in /angular2/http.js rather than /node_modules/angular2/http.js

When I switch from "node" module compilation to "classic" the result is the same.

Any thoughts on how to proceed?

3
  • 1
    I solved the problem by specifying the "paths" setting in System.config for the necessary files. Commented Apr 10, 2016 at 17:14
  • 1
    Hi @ktamlyn could you add this System.config here as an answer. It could be helpful for next developers. Commented Apr 12, 2016 at 13:54
  • Agreed, had to wait to answer the question myself by Stackoverflow rules. Commented Apr 12, 2016 at 14:16

1 Answer 1

1

Here was my solution to this problem using the paths property in the System.config object:

    System.config({
        defaultJSExtensions: true,
        baseURL: "/",
        paths: {
            'modules/worker/*': '/modules/worker/*',
            'angular2/*': '/node_modules/angular2/*',
            'rxjs/*': '/node_modules/rxjs/*',
        },
        packages: {
            modules : {
                worker: {
                    format: 'register',
                    defaultExtension: 'js'
                }
            }
        }
    });
    System.import('modules/worker/main')
            .then(null, console.error.bind(console));

For each asset that was being loaded outside main.js (all external libraries) I had to directly point to them in the paths config property. This list would be different depending on the dependencies of your published Typescript classes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.