diff --git a/systemjs/systemjs-0.18.4-tests.ts b/systemjs/systemjs-0.18.4-tests.ts new file mode 100644 index 0000000000..aebc610493 --- /dev/null +++ b/systemjs/systemjs-0.18.4-tests.ts @@ -0,0 +1,10 @@ +/// + +import System = require('systemjs'); + +System.config({ + baseURL: '/', + paths: {'*': '*.js?v=0.18.4'} +}); + +System.import('app'); diff --git a/systemjs/systemjs-0.18.4.d.ts b/systemjs/systemjs-0.18.4.d.ts new file mode 100644 index 0000000000..0128ff5844 --- /dev/null +++ b/systemjs/systemjs-0.18.4.d.ts @@ -0,0 +1,22 @@ +// Type definitions for System.js 0.18.4 +// Project: https://github.com/systemjs/systemjs +// Definitions by: Ludovic HENIN , Nathan Walker +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface System { + import(name: string): any; + defined: any; + amdDefine: () => void; + amdRequire: () => void; + baseURL: string; + paths: { [key: string]: string }; + meta: { [key: string]: Object }; + config: any; + _nodeRequire: (name: string) => any; +} + +declare var System: System; + +declare module "systemjs" { + export = System; +} diff --git a/systemjs/systemjs-tests.ts b/systemjs/systemjs-tests.ts index 7a56ef8dc9..d0a199864d 100644 --- a/systemjs/systemjs-tests.ts +++ b/systemjs/systemjs-tests.ts @@ -3,8 +3,35 @@ import System = require('systemjs'); System.config({ - baseURL: '/', - paths: {'*': '*.js?v=0.18.4'} + baseURL: '/app' }); -System.import('app'); \ No newline at end of file +System.import('main.js'); + +System.config({ + // or 'traceur' or 'typescript' + transpiler: 'babel', + // or traceurOptions or typescriptOptions + babelOptions: { + + } +}); + + +System.config({ + map: { + traceur: 'path/to/traceur.js' + } +}); + +System.transpiler = 'traceur'; + + +// loads './app.js' from the current directory +System.import('./app.js').then(function (m) { + console.log(m); +}); + +System.import('lodash').then(function (_) { + console.log(_); +}); diff --git a/systemjs/systemjs.d.ts b/systemjs/systemjs.d.ts index 0128ff5844..a04ee7a90d 100644 --- a/systemjs/systemjs.d.ts +++ b/systemjs/systemjs.d.ts @@ -1,22 +1,327 @@ -// Type definitions for System.js 0.18.4 +// Type definitions for SystemJS 0.19.29 // Project: https://github.com/systemjs/systemjs -// Definitions by: Ludovic HENIN , Nathan Walker +// Definitions by: Ludovic HENIN , Nathan Walker , Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface System { - import(name: string): any; - defined: any; - amdDefine: () => void; - amdRequire: () => void; - baseURL: string; - paths: { [key: string]: string }; - meta: { [key: string]: Object }; - config: any; - _nodeRequire: (name: string) => any; + +declare namespace SystemJSLoader { + + type ModulesList = { [bundleName: string]: Array }; + + type PackageList = { [packageName: string]: T }; + + /** + * The following module formats are supported: + * + * - esm: ECMAScript Module (previously referred to as es6) + * - cjs: CommonJS + * - amd: Asynchronous Module Definition + * - global: Global shim module format + * - register: System.register or System.registerDynamic compatibility module format + * + */ + type ModuleFormat = "esm" | "cjs" | "amd" | "global" | "register"; + + /** + * Sets the module name of the transpiler to be used for loading ES6 modules. + * Represents a module name for System.import that must resolve to either Traceur, Babel or TypeScript. + * When set to traceur, babel or typescript, loading will be automatically configured as far as possible. + */ + type Transpiler = "traceur" | "babel" | "typescript"; + + + type ConfigMap = PackageList; + + type ConfigMeta = PackageList; + + interface MetaConfig { + /** + * Sets in what format the module is loaded. + */ + format?: ModuleFormat; + + /** + * For the global format, when automatic detection of exports is not enough, a custom exports meta value can be set. + * This tells the loader what global name to use as the module's export value. + */ + exports?: string; + + /** + * Dependencies to load before this module. Goes through regular paths and map normalization. + * Only supported for the cjs, amd and global formats. + */ + deps?: Array; + + /** + * A map of global names to module names that should be defined only for the execution of this module. + * Enables use of legacy code that expects certain globals to be present. + * Referenced modules automatically becomes dependencies. Only supported for the cjs and global formats. + */ + globals?: string; + + /** + * Set a loader for this meta path. + */ + loader?: string; + + /** + * For plugin transpilers to set the source map of their transpilation. + */ + sourceMap?: any; + + /** + * Load the module using