There seems to be an issue with how SystemJS detects module formats automatically.
It uses a regular expression to determine whether the source is in ES6 and requires transpilation:
// The regex used for detecting ES6 modules may not be accurate but covers most cases
var esmRegEx = /(^\s*|[}\);\n]\s*)(import\s*(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s*from\s*['"]|\{)|export\s+\*\s+from\s+["']|export\s*(\{|default|function|class|var|const|let|async\s+function))/;
Interestingly, TypeScript versions 2.3.1 and 2.3.2 include a comment in their source code that matches this regex:
// In declaration files, exported modules might need to be accessed elsewhere as well. For example:
// declare module "a" { export type T = number; }
// declare module "b" { import { T } from "a"; export const x: T; }
So when troubleshooting this issue, you might notice that SystemJS loads a transpiler (TypeScript), recognizes it as needing transpilation for ES6, tries to load another transpiler, and ultimately skips transpiling your own code (main.ts
) altogether.
To resolve this, specify the proper format for TypeScript as 'global' in the SystemJS configuration at the top level:
meta: {typescript: {format: 'global'}}