-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(package): updated to angular2 beta.15
fixes #106 updated build and publish flow
- Loading branch information
Showing
18 changed files
with
318 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
/*eslint no-console: 0, no-sync: 0*/ | ||
|
||
// System.js bundler | ||
// simple and yet reusable system.js bundler | ||
// bundles, minifies and gzips | ||
|
||
const fs = require('fs'); | ||
const del = require('del'); | ||
const path = require('path'); | ||
const zlib = require('zlib'); | ||
const async = require('async'); | ||
const Builder = require('systemjs-builder'); | ||
|
||
const pkg = require('../package.json'); | ||
const name = pkg.name; | ||
const targetFolder = path.resolve('./bundles'); | ||
console.log(targetFolder) | ||
async.waterfall([ | ||
cleanBundlesFolder, | ||
getSystemJsBundleConfig, | ||
buildSystemJs({minify: false, sourceMaps: true, mangle: false}), | ||
getSystemJsBundleConfig, | ||
buildSystemJs({minify: true, sourceMaps: true, mangle: false}), | ||
gzipSystemJsBundle | ||
], err => { | ||
if (err) { | ||
throw err; | ||
} | ||
}); | ||
|
||
function getSystemJsBundleConfig(cb) { | ||
const config = { | ||
baseURL: '..', | ||
transpiler: 'typescript', | ||
typescriptOptions: { | ||
module: 'cjs' | ||
}, | ||
map: { | ||
typescript: path.resolve('node_modules/typescript/lib/typescript.js'), | ||
angular2: path.resolve('node_modules/angular2'), | ||
rxjs: path.resolve('node_modules/rxjs') | ||
}, | ||
paths: { | ||
'*': '*.js' | ||
} | ||
}; | ||
|
||
config.meta = ['angular2', 'rxjs'].reduce((memo, currentValue) => { | ||
memo[path.resolve(`node_modules/${currentValue}/*`)] = {build: false}; | ||
return memo; | ||
}, {}); | ||
config.meta.moment = {build: false}; | ||
console.log(config.meta) | ||
return cb(null, config); | ||
} | ||
|
||
function cleanBundlesFolder(cb) { | ||
return del(targetFolder) | ||
.then(paths => { | ||
console.log('Deleted files and folders:\n', paths.join('\n')); | ||
cb(); | ||
}); | ||
} | ||
|
||
function buildSystemJs(options) { | ||
return (config, cb) => { | ||
const minPostFix = options && options.minify ? '.min' : ''; | ||
const fileName = `${name}${minPostFix}.js`; | ||
const dest = path.resolve(__dirname, targetFolder, fileName); | ||
const builder = new Builder(); | ||
|
||
console.log('Bundling system.js file:', fileName, options); | ||
builder.config(config); | ||
return builder | ||
.bundle([name, name].join('/'), dest, options) | ||
.then(() => cb()) | ||
.catch(cb); | ||
}; | ||
} | ||
|
||
function gzipSystemJsBundle(cb) { | ||
const files = fs | ||
.readdirSync(path.resolve(targetFolder)) | ||
.map(file => path.resolve(targetFolder, file)) | ||
.filter(file => fs.statSync(file).isFile()) | ||
.filter(file => path.extname(file) !== 'gz'); | ||
|
||
return async.eachSeries(files, (file, gzipcb) => { | ||
process.nextTick(() => { | ||
console.log('Gzipping ', file); | ||
const gzip = zlib.createGzip({level: 9}); | ||
const inp = fs.createReadStream(file); | ||
const out = fs.createWriteStream(`${file}.gz`); | ||
|
||
inp.on('end', () => gzipcb()); | ||
inp.on('error', err => gzipcb(err)); | ||
return inp.pipe(gzip).pipe(out); | ||
}); | ||
}, cb); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "./node_modules/eslint-config-valorsoft/.eslintrc.json", | ||
"env": { | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
.idea | ||
demo | ||
build | ||
gulp-tasks | ||
logs | ||
|
||
# typings | ||
typings | ||
|
||
# testing | ||
karma.conf.js | ||
test.bundle.js | ||
coverage | ||
|
||
# demo build | ||
demo | ||
demo-build | ||
webpack.config.js | ||
|
||
#typescript sources | ||
*.ts | ||
*.js.map | ||
!*.d.ts | ||
/components/**/*.ts | ||
!/components/**/*.d.ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Dmitriy Shekhovtsov <[email protected]> | ||
Copyright (c) 2015 Valor Software | ||
Copyright (c) 2015-2016 Dmitriy Shekhovtsov <[email protected]> | ||
Copyright (c) 2015-2016 Valor Software | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.