1

I'm using TypeScript to generate a single outFile that compiles my modules, loaded with SystemJS. When I follow the documentation on loading bundles, as suggested by this SO answer, I get an error:

Uncaught (in promise) Error: Module instantiation did not call an anonymous or correctly named System.register.
    Instantiating http://localhost:50001/Content/js/app.js
    Loading app.js
        at vendor.js?v=c419d08…:4

Here is the setup script in my index.html file:

SystemJS.import("/Content/js/app.js").then(function (mod) {
    return SystemJS.import("admin/js/startup");
});

app.js looks like this:

System.register("shared/js/utilities", [], function (exports_1, context_1) {
    ...
});

System.register("admin/js/startup", ["shared/js/utilities"], function (exports_2, context_2) {
    ...
});

My tsconfig.json, if it helps:

{
    "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5",
        "module": "system",
        "outFile": "app.js"
    },
    "compileOnSave": true,
    "exclude": [
        "node_modules",
        "wwwroot"
    ]
}

UPDATE: I had been using systemjs/dist/system-production.js, because the documentation states that modules already transpiled into the System.register format, which is done by TypeScript, can be loaded by the production loader. If I switch to using systemjs/dist/system.js, I do not get the errors. I still don't see how I am getting this error from the production loader if I'm already working with System.register formatted modules.

3
  • It looks like the error originates somewhere in vendor.js ... Commented Apr 18, 2017 at 19:46
  • @martin Yes, that contains the systemjs/dist/system-production.js file concatenated with other 3rd party library files. If I look around that part of the code in the dev tools, it's designed to throw that error if some object is missing a 'reference' property or something. I'm not sure what it means. Commented Apr 18, 2017 at 20:58
  • Same problem here. system-production.js generates errors when the modules are bundled by the typescript compiler. There are no errors when loading system.js. Did you solve the issue? Commented Jun 2, 2017 at 13:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.