Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobrandao committed Nov 26, 2016
0 parents commit 47d6835
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vscode

jspm_packages
node_modules

dev

.eslintrc
.editorconfig
12 changes: 12 additions & 0 deletions build/compiler-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
modules: 'system',
moduleIds: false,
comments: false,
compact: false,
stage: 2,
optional: [
'es7.decorators',
'optimisation.modules.system'
],
sourceMaps: true
};
4 changes: 4 additions & 0 deletions build/paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
source: 'src/**/*.js',
devOutput: 'dev/'
};
53 changes: 53 additions & 0 deletions build/tasks/build.js
Original file line number Diff line number Diff line change
@@ -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
);
});
9 changes: 9 additions & 0 deletions build/tasks/clean.js
Original file line number Diff line number Diff line change
@@ -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));
});
178 changes: 178 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -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:[email protected]",
"babel-runtime": "npm:[email protected]",
"clean-css": "npm:[email protected]",
"core-js": "npm:[email protected]",
"css": "github:systemjs/[email protected]",
"jquery": "npm:[email protected]",
"knockout": "github:knockout/[email protected]",
"knockout-original": "github:knockout/[email protected]",
"github:jspm/[email protected]": {
"assert": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"buffer": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"events": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"Base64": "npm:[email protected]",
"events": "github:jspm/[email protected]",
"inherits": "npm:[email protected]",
"stream": "github:jspm/[email protected]",
"url": "github:jspm/[email protected]",
"util": "github:jspm/[email protected]"
},
"github:jspm/[email protected]": {
"https-browserify": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"os-browserify": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"path-browserify": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"process": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"stream-browserify": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"url": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"util": "npm:[email protected]"
},
"github:jspm/[email protected]": {
"vm-browserify": "npm:[email protected]"
},
"npm:[email protected]": {
"fs": "github:jspm/[email protected]",
"module": "github:jspm/[email protected]",
"path": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"assert": "github:jspm/[email protected]",
"buffer": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]",
"util": "npm:[email protected]"
},
"npm:[email protected]": {
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"base64-js": "npm:[email protected]",
"child_process": "github:jspm/[email protected]",
"fs": "github:jspm/[email protected]",
"ieee754": "npm:[email protected]",
"isarray": "npm:[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"buffer": "github:jspm/[email protected]",
"commander": "npm:[email protected]",
"fs": "github:jspm/[email protected]",
"http": "github:jspm/[email protected]",
"https": "github:jspm/[email protected]",
"os": "github:jspm/[email protected]",
"path": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]",
"source-map": "npm:[email protected]",
"url": "github:jspm/[email protected]",
"util": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"child_process": "github:jspm/[email protected]",
"events": "github:jspm/[email protected]",
"fs": "github:jspm/[email protected]",
"graceful-readlink": "npm:[email protected]",
"path": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"fs": "github:jspm/[email protected]",
"path": "github:jspm/[email protected]",
"process": "github:jspm/[email protected]",
"systemjs-json": "github:systemjs/[email protected]"
},
"npm:[email protected]": {
"buffer": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"fs": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"http": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"util": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"os": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"assert": "github:jspm/[email protected]",
"fs": "github:jspm/[email protected]",
"vm": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"buffer": "github:jspm/[email protected]",
"core-util-is": "npm:[email protected]",
"events": "github:jspm/[email protected]",
"inherits": "npm:[email protected]",
"isarray": "npm:[email protected]",
"process": "github:jspm/[email protected]",
"stream-browserify": "npm:[email protected]",
"string_decoder": "npm:[email protected]"
},
"npm:[email protected]": {
"amdefine": "npm:[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"events": "github:jspm/[email protected]",
"inherits": "npm:[email protected]",
"readable-stream": "npm:[email protected]"
},
"npm:[email protected]": {
"buffer": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"assert": "github:jspm/[email protected]",
"punycode": "npm:[email protected]",
"querystring": "npm:[email protected]",
"util": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"inherits": "npm:[email protected]",
"process": "github:jspm/[email protected]"
},
"npm:[email protected]": {
"indexof": "npm:[email protected]"
}
}
});
3 changes: 3 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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');
32 changes: 32 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>

<head>
<meta charset='utf-8'>
<title>Testing</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>

<script src="jspm_packages/system.js"></script>
<script>
window.define = System.amdDefine;
window.require = window.requirejs = System.amdRequire.bind(System);
</script>
<script src='config.js'></script>
</head>

<body>
<div class="page-header">
<h1>Testing</h1>
</div>

<div data-bind="if: isInitialized" class="container">
<h2 data-bind="text: message"></h2>
<h4 data-bind="text: user.name"></h4>
</div>

<script>
System.import('index-bootstrapper');
</script>
</body>

</html>
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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/[email protected]",
"knockout": "github:knockout/[email protected]"
},
"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"
}
}
4 changes: 4 additions & 0 deletions src/index-bootstrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ko from 'knockout';
import IndexViewModel from 'index-viewmodel';

ko.applyBindings(IndexViewModel);
17 changes: 17 additions & 0 deletions src/index-viewmodel.js
Original file line number Diff line number Diff line change
@@ -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();
7 changes: 7 additions & 0 deletions src/users/user-model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class UserModel {
constructor(data){
this.name = data.name;
}
}

export default UserModel;

0 comments on commit 47d6835

Please sign in to comment.