From 4d2922b5a3f92b01c03e443e60cc82fce37f6fcf Mon Sep 17 00:00:00 2001 From: Tomas Varga Date: Tue, 30 Jan 2018 17:25:41 +0100 Subject: [PATCH] Initial commit - the working setup --- .gitignore | 1 + README.md | 12 ++++ index.html | 15 +++++ package-lock.json | 36 +++++++++++ package.json | 23 +++++++ src/main.ts | 11 ++++ src/utils.ts | 4 ++ system.config.js | 29 +++++++++ tsconfig.json | 11 ++++ tslint.json | 148 ++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 290 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 index.html create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/main.ts create mode 100644 src/utils.ts create mode 100644 system.config.js create mode 100644 tsconfig.json create mode 100644 tslint.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..572d1c2 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# SystemJS minimal TypeScript setup + +A minimal SystemJS module loader setup with TypeScript support. + +## Usage + +Just install dependencies & point a webserver to (or run it in) the project's root. + +``` +npm install +http-server +``` diff --git a/index.html b/index.html new file mode 100644 index 0000000..7ab2028 --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + + SystemJS Typescript Sample + + +
+ + + + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..08511d7 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,36 @@ +{ + "name": "systemjs-typescript-minimal", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/whatwg-fetch": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/whatwg-fetch/-/whatwg-fetch-0.0.33.tgz", + "integrity": "sha1-GcDShjyMsjgPIaHHNrecv3iVuxM=", + "requires": { + "@types/whatwg-streams": "0.0.4" + } + }, + "@types/whatwg-streams": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@types/whatwg-streams/-/whatwg-streams-0.0.4.tgz", + "integrity": "sha512-dM5YQytWb1EunntizWnsAsADJxbXhHQyPoRxXlfEMPULcnbgzB02qZ8KI/K5yFItulzoidxWbX4OO/w4FN92Sg==" + }, + "plugin-typescript": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/plugin-typescript/-/plugin-typescript-7.1.0.tgz", + "integrity": "sha1-XZLTrmACFJaUja0fko1KOvCYxnU=" + }, + "systemjs": { + "version": "0.20.19", + "resolved": "https://registry.npmjs.org/systemjs/-/systemjs-0.20.19.tgz", + "integrity": "sha512-H/rKwNEEyej/+IhkmFNmKFyJul8tbH/muiPq5TyNoVTwsGhUjRsN3NlFnFQUvFXA3+GQmsXkCNXU6QKPl779aw==" + }, + "typescript": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.3.tgz", + "integrity": "sha512-ptLSQs2S4QuS6/OD1eAKG+S5G8QQtrU5RT32JULdZQtM1L3WTi34Wsu48Yndzi8xsObRAB9RPt/KhA9wlpEF6w==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..0fc1112 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "systemjs-typescript-minimal", + "version": "0.0.1", + "description": "A minimal SystemJS module loader setup with TypeScript support", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "systemjs", + "typescript", + "starter", + "sample" + ], + "author": "Tomas Varga ", + "license": "ISC", + "dependencies": { + "@types/whatwg-fetch": "0.0.33", + "plugin-typescript": "^7.1.0", + "systemjs": "^0.20.19", + "typescript": "^2.5.3" + } +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..11ff85c --- /dev/null +++ b/src/main.ts @@ -0,0 +1,11 @@ +import { showMessage } from './utils'; + +console.log('Hello from es5!'); +setTimeout(() => { + init('Hello from Typescript!'); +}); + +function init(note: string): void { + console.log(note); + showMessage(note, '#whatever-app'); +} diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..c63e450 --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,4 @@ +export const showMessage = (message: string, elemSelector: string): void => { + var elem = document.querySelector(elemSelector); + if (elem) elem.innerHTML = message; +}; diff --git a/system.config.js b/system.config.js new file mode 100644 index 0000000..e36dbb0 --- /dev/null +++ b/system.config.js @@ -0,0 +1,29 @@ +/* global SystemJS */ + +SystemJS.config({ + transpiler: 'ts', + typescriptOptions: { + tsconfig: true + }, + packages: { + ts: { + main: 'lib/plugin.js' + }, + typescript: { + main: 'lib/typescript.js', + meta: { + 'lib/typescript.js': { + 'exports': 'ts' + } + } + }, + src: { + defaultExtension: 'ts', + format: 'esm' + } + }, + map: { + ts: 'node_modules/plugin-typescript', + typescript: 'node_modules/typescript' + }, +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ef08001 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "system", + "noImplicitAny": false, + "noUnusedLocals": true, + "noUnusedParameters": false, + "typeRoots": "typings", + "types": [ "whatwg-fetch" ], + "lib": ["dom", "es5", "es2015.promise"] + } +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..0a0b561 --- /dev/null +++ b/tslint.json @@ -0,0 +1,148 @@ +{ + "rules": { + "trailing-comma": [ + true, + { + "multiline": "always", + "singleline": "never" + } + ], + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "comment-format": [ + false, + "check-space" + ], + "curly": [ + true, + "ignore-same-line" + ], + "eofline": true, + "forin": true, + "import-blacklist": [ + true, + "rxjs" + ], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-misused-new": true, + "no-non-null-assertion": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-whitespace" + ], + "prefer-const": true, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + ["app", "mup"], + "kebab-case" + ], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true + } +}