From 47d683510fadfcd3c5f12d208551f192c0048bbe Mon Sep 17 00:00:00 2001 From: "ricardo.brandao" Date: Sat, 26 Nov 2016 22:36:55 +0000 Subject: [PATCH] First commit. --- .gitignore | 9 ++ build/compiler-options.js | 12 +++ build/paths.js | 4 + build/tasks/build.js | 53 ++++++++++++ build/tasks/clean.js | 9 ++ config.js | 178 ++++++++++++++++++++++++++++++++++++++ gulpfile.js | 3 + index.html | 32 +++++++ package.json | 31 +++++++ src/index-bootstrapper.js | 4 + src/index-viewmodel.js | 17 ++++ src/users/user-model.js | 7 ++ 12 files changed, 359 insertions(+) create mode 100644 .gitignore create mode 100644 build/compiler-options.js create mode 100644 build/paths.js create mode 100644 build/tasks/build.js create mode 100644 build/tasks/clean.js create mode 100644 config.js create mode 100644 gulpfile.js create mode 100644 index.html create mode 100644 package.json create mode 100644 src/index-bootstrapper.js create mode 100644 src/index-viewmodel.js create mode 100644 src/users/user-model.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a4f578b --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.vscode + +jspm_packages +node_modules + +dev + +.eslintrc +.editorconfig diff --git a/build/compiler-options.js b/build/compiler-options.js new file mode 100644 index 0000000..1cb2862 --- /dev/null +++ b/build/compiler-options.js @@ -0,0 +1,12 @@ +module.exports = { + modules: 'system', + moduleIds: false, + comments: false, + compact: false, + stage: 2, + optional: [ + 'es7.decorators', + 'optimisation.modules.system' + ], + sourceMaps: true +}; diff --git a/build/paths.js b/build/paths.js new file mode 100644 index 0000000..4ba65bc --- /dev/null +++ b/build/paths.js @@ -0,0 +1,4 @@ +module.exports = { + source: 'src/**/*.js', + devOutput: 'dev/' +}; diff --git a/build/tasks/build.js b/build/tasks/build.js new file mode 100644 index 0000000..9786055 --- /dev/null +++ b/build/tasks/build.js @@ -0,0 +1,53 @@ +var gulp = require('gulp'); +var plumber = require('gulp-plumber'); +var runSequence = require('run-sequence'); +var through2 = require('through2'); + +var compilerOptions = require('../compiler-options'); +var paths = require('../paths'); + +var jspm = require('jspm'); +var builder = new jspm.Builder('.', 'config.js'); +jspm.setPackagePath('.'); +builder.loader.paths['*'] = 'src/*'; +builder.config({ + babelOptions: { + modules: 'system', + moduleIds: false, + comments: false, + compact: false, + stage: 2, + externalHelpers: true, + optional: [ + 'es7.decorators', + 'optimisation.modules.system' + ] + }, + meta: {} +}); + +var compileAndWriteToDisk = function (file, en, callback) { + builder.compile(file.path.replace(file.base, ''), + file.path.replace('src', 'dev'), + { minify: true, transpile: true, sourceMaps: true }) + .then(function (output) { + callback(); + }) + .catch(function (error) { + callback(error); + }); +} + +gulp.task('build-js', function () { + return gulp.src(paths.source) + .pipe(plumber()) + .pipe(through2.obj(compileAndWriteToDisk)); +}); + +gulp.task('build', function (callback) { + return runSequence( + 'clean', + 'build-js', + callback + ); +}); diff --git a/build/tasks/clean.js b/build/tasks/clean.js new file mode 100644 index 0000000..95c3e04 --- /dev/null +++ b/build/tasks/clean.js @@ -0,0 +1,9 @@ +var del = require('del'); +var gulp = require('gulp'); +var vinylPaths = require('vinyl-paths'); + +var paths = require('../paths'); + +gulp.task('clean', function() { + return gulp.src([paths.devOutput]).pipe(vinylPaths(del)); +}); diff --git a/config.js b/config.js new file mode 100644 index 0000000..5d4c75e --- /dev/null +++ b/config.js @@ -0,0 +1,178 @@ +System.config({ + baseURL: "/", + defaultJSExtensions: true, + transpiler: "babel", + babelOptions: { + "optional": [ + "runtime" + ] + }, + paths: { + "*": "src/*", + "github:*": "jspm_packages/github/*", + "npm:*": "jspm_packages/npm/*" + }, + + map: { + "babel": "npm:babel-core@5.8.38", + "babel-runtime": "npm:babel-runtime@5.8.38", + "clean-css": "npm:clean-css@3.4.21", + "core-js": "npm:core-js@1.2.7", + "css": "github:systemjs/plugin-css@0.1.32", + "jquery": "npm:jquery@3.1.1", + "knockout": "github:knockout/knockout@3.4.1", + "knockout-original": "github:knockout/knockout@3.4.1", + "github:jspm/nodelibs-assert@0.1.0": { + "assert": "npm:assert@1.4.1" + }, + "github:jspm/nodelibs-buffer@0.1.0": { + "buffer": "npm:buffer@3.6.0" + }, + "github:jspm/nodelibs-events@0.1.1": { + "events": "npm:events@1.0.2" + }, + "github:jspm/nodelibs-http@1.7.1": { + "Base64": "npm:Base64@0.2.1", + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "github:jspm/nodelibs-https@0.1.0": { + "https-browserify": "npm:https-browserify@0.0.0" + }, + "github:jspm/nodelibs-os@0.1.0": { + "os-browserify": "npm:os-browserify@0.1.2" + }, + "github:jspm/nodelibs-path@0.1.0": { + "path-browserify": "npm:path-browserify@0.0.0" + }, + "github:jspm/nodelibs-process@0.1.2": { + "process": "npm:process@0.11.9" + }, + "github:jspm/nodelibs-stream@0.1.0": { + "stream-browserify": "npm:stream-browserify@1.0.0" + }, + "github:jspm/nodelibs-url@0.1.0": { + "url": "npm:url@0.10.3" + }, + "github:jspm/nodelibs-util@0.1.0": { + "util": "npm:util@0.10.3" + }, + "github:jspm/nodelibs-vm@0.1.0": { + "vm-browserify": "npm:vm-browserify@0.0.4" + }, + "npm:amdefine@1.0.1": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "module": "github:jspm/nodelibs-module@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:assert@1.4.1": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "util": "npm:util@0.10.3" + }, + "npm:babel-runtime@5.8.38": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:buffer@3.6.0": { + "base64-js": "npm:base64-js@0.0.8", + "child_process": "github:jspm/nodelibs-child_process@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "ieee754": "npm:ieee754@1.1.8", + "isarray": "npm:isarray@1.0.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:clean-css@3.4.21": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "commander": "npm:commander@2.8.1", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "http": "github:jspm/nodelibs-http@1.7.1", + "https": "github:jspm/nodelibs-https@0.1.0", + "os": "github:jspm/nodelibs-os@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "source-map": "npm:source-map@0.4.4", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:commander@2.8.1": { + "child_process": "github:jspm/nodelibs-child_process@0.1.0", + "events": "github:jspm/nodelibs-events@0.1.1", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "graceful-readlink": "npm:graceful-readlink@1.0.1", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:core-js@1.2.7": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.2", + "systemjs-json": "github:systemjs/plugin-json@0.1.2" + }, + "npm:core-util-is@1.0.2": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, + "npm:graceful-readlink@1.0.1": { + "fs": "github:jspm/nodelibs-fs@0.1.2" + }, + "npm:https-browserify@0.0.0": { + "http": "github:jspm/nodelibs-http@1.7.1" + }, + "npm:inherits@2.0.1": { + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:os-browserify@0.1.2": { + "os": "github:jspm/nodelibs-os@0.1.0" + }, + "npm:path-browserify@0.0.0": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:process@0.11.9": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "vm": "github:jspm/nodelibs-vm@0.1.0" + }, + "npm:punycode@1.3.2": { + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:readable-stream@1.1.14": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "core-util-is": "npm:core-util-is@1.0.2", + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "isarray": "npm:isarray@0.0.1", + "process": "github:jspm/nodelibs-process@0.1.2", + "stream-browserify": "npm:stream-browserify@1.0.0", + "string_decoder": "npm:string_decoder@0.10.31" + }, + "npm:source-map@0.4.4": { + "amdefine": "npm:amdefine@1.0.1", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:stream-browserify@1.0.0": { + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "readable-stream": "npm:readable-stream@1.1.14" + }, + "npm:string_decoder@0.10.31": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, + "npm:url@0.10.3": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "punycode": "npm:punycode@1.3.2", + "querystring": "npm:querystring@0.2.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:util@0.10.3": { + "inherits": "npm:inherits@2.0.1", + "process": "github:jspm/nodelibs-process@0.1.2" + }, + "npm:vm-browserify@0.0.4": { + "indexof": "npm:indexof@0.0.1" + } + } +}); diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..4b28ec1 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,3 @@ +// all gulp tasks are located in the ./build/tasks directory +// gulp configuration is in files in ./build directory +require('require-dir')('build/tasks'); diff --git a/index.html b/index.html new file mode 100644 index 0000000..222dee4 --- /dev/null +++ b/index.html @@ -0,0 +1,32 @@ + + + + + + Testing + + + + + + + + + + +
+

+

+
+ + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..511964b --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "systemjs-issue", + "version": "1.0.0", + "jspm": { + "dependencies": { + "clean-css": "npm:clean-css@^3.4.4", + "css": "github:systemjs/plugin-css@^0.1.18", + "jquery": "github:components/jquery@2.2.4", + "knockout": "github:knockout/knockout@3.4.1" + }, + "devDependencies": { + "babel": "npm:babel-core@^5.8.24", + "babel-runtime": "npm:babel-runtime@^5.8.24", + "core-js": "npm:core-js@^1.1.4" + } + }, + "devDependencies": { + "babel-core": "^6.18.2", + "del": "^1.2.0", + "fs": "0.0.2", + "gulp": "^3.9.0", + "gulp-plumber": "^1.0.1", + "gulp-shell": "^0.4.2", + "gulp-util": "^3.0.6", + "jspm": "^0.16.48", + "require-dir": "^0.3.0", + "run-sequence": "^1.1.2", + "through2": "^2.0.1", + "vinyl-paths": "^1.0.0" + } +} diff --git a/src/index-bootstrapper.js b/src/index-bootstrapper.js new file mode 100644 index 0000000..b689b28 --- /dev/null +++ b/src/index-bootstrapper.js @@ -0,0 +1,4 @@ +import ko from 'knockout'; +import IndexViewModel from 'index-viewmodel'; + +ko.applyBindings(IndexViewModel); diff --git a/src/index-viewmodel.js b/src/index-viewmodel.js new file mode 100644 index 0000000..5dadd02 --- /dev/null +++ b/src/index-viewmodel.js @@ -0,0 +1,17 @@ +import ko from 'knockout'; +import UserModel from 'users/user-model'; + +class IndexViewModel { + constructor() { + this.message = 'Hello, World'; + + this.initialize(); + } + + initialize() { + this.user = new UserModel({name: 'John Doe'}); + this.isInitialized = ko.observable(true); + } +} + +export default new IndexViewModel(); diff --git a/src/users/user-model.js b/src/users/user-model.js new file mode 100644 index 0000000..23c2f8a --- /dev/null +++ b/src/users/user-model.js @@ -0,0 +1,7 @@ +class UserModel { + constructor(data){ + this.name = data.name; + } +} + +export default UserModel;