SystemJS will probably work as follows:
> System.import('app') - where is 'app'? > map: { 'app': './src', ... - Okay, 'app' is './src' - './src' ?? > packages: { app: { main: './main.ts', - Aha, './src/main.ts' > ./src/main.ts - Which format?? - 'system' ? -> No - 'esm' ? -> No (if YES, use transpiler: 'typescript') - 'amd' ? -> No - 'cjs' ? -> No - 'global' ? -> Yes -> No transpiler needed. > evaluate ./src/main.ts - What is ':string' in JavaScript? - Exception!!!
Module format definition
If the module format is not installed, automatic regular expression detection. The detection of this module is not always completely accurate, but is well suited for most use cases.
If automatic detection fails, you must specify it manually.
Method 1: Add Hints to the Source
ex1: add export (from question)
const foo: boolean = 'foo'; console.log(foo); export default null;
ex2: add export
export const foo: boolean = 'foo'; console.log(foo);
Method 2. Add format configuration
ex1: packages / path / meta / template (./main.ts or. /*.ts)/ format
packages: { app: { main: './main.ts', defaultExtension: 'ts', meta: { './main.ts': { format: 'esm' } } }
ex2: packages / path / format
packages: { app: { main: './main.ts', defaultExtension: 'ts', format: 'esm' } }
ex3: meta / pattern (application / prefix required) / format (external packages)
meta: { 'app/main.ts': { format: 'esm' } }
thatseeyou
source share