TigrouMeow
TigrouMeow

Reputation: 3779

Why is SystemJS is looking for source-map-support.js?

I have my whole setup here: https://github.com/jordymeow/meowbs-2016

I believe it's quite clean, but it's not perfect. As it is, it works, but in the index.html file, try to switch those comments:

//System.import('./app/app');
System.import('./src/app.ts');

Basically, instead of using the compiled JS (performed automatically by Atom editor), we could load the app.ts directly but that doesn't work. SystemJS is looking for "source-map-support.js" and fails at it. I am not sure why I would need this dependency and I believe I have a configuration issue (or many of them).

You will probably see many things wrong in this project as well ;) Don't hesitate to tell me.

Thanks for your help.

Upvotes: 1

Views: 408

Answers (1)

artem
artem

Reputation: 51629

In typescript 2.1, they added optional dependency on source-map-support - there is this function in typescript.js:

      tryEnableSourceMapsForHost: function() {
        try {
          require('source-map-support').install();
        } catch (e) {}
      },

However, SystemJS can't detect that it's optional - in order to make require work in the browser, it scans source code for require calls, tries to load all required modules, and fails.

You can install source-map-support module, or you can simply map it to special module named @empty in jspm.config.js by adding this line to map:

"source-map-support": "@empty",

Then you also need to add defaultExtension: 'ts' to src package config, otherwise import { AppModule } from "./app.module"; will try to load app.module.js.

In all, the changed fragment in jspm.config.js looks like

    "src": {
      "defaultExtension": "ts",
      "meta": {
        "*.ts": {
          "loader": "plugin-typescript"
        }
      }
    }
  },

  map: {
    "source-map-support": "@empty",

Upvotes: 1

Related Questions