forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.make-packages.js
58 lines (49 loc) · 1.89 KB
/
.make-packages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var pkg = require('./package.json');
var fs = require('fs');
var mkdirp = require('mkdirp');
var path = require('path');
var Builder = require('systemjs-builder');
delete pkg.scripts;
var cjsPkg = Object.assign({}, pkg, {
name: 'rxjs',
main: 'Rx.js',
typings: 'Rx.d.ts'
});
var es6Pkg = Object.assign({}, cjsPkg, {
name: 'rxjs-es',
});
fs.writeFileSync('dist/cjs/package.json', JSON.stringify(cjsPkg, null, 2));
fs.writeFileSync('dist/cjs/LICENSE.txt', fs.readFileSync('./LICENSE.txt').toString());
fs.writeFileSync('dist/cjs/README.md', fs.readFileSync('./README.md').toString());
// Bundles for CJS only
mkdirp.sync('dist/cjs/bundles');
fs.writeFileSync('dist/cjs/bundles/Rx.umd.js', fs.readFileSync('dist/global/Rx.umd.js').toString());
fs.writeFileSync('dist/cjs/bundles/Rx.umd.min.js', fs.readFileSync('dist/global/Rx.umd.min.js').toString());
fs.writeFileSync('dist/cjs/bundles/Rx.umd.min.js.map', fs.readFileSync('dist/global/Rx.umd.min.js.map').toString());
fs.writeFileSync('dist/es6/package.json', JSON.stringify(es6Pkg, null, 2));
fs.writeFileSync('dist/es6/LICENSE.txt', fs.readFileSync('./LICENSE.txt').toString());
fs.writeFileSync('dist/es6/README.md', fs.readFileSync('./README.md').toString());
var config = {
baseURL: 'dist',
paths: {
'rxjs/*': 'cjs/*.js'
}
};
var devBuilder = new Builder();
devBuilder.config(config);
devBuilder.build('rxjs/Rx', path.resolve(__dirname, 'dist/cjs/bundles/Rx.js')).then(function() {
console.log('done with dev');
var prodBuilder = new Builder();
prodBuilder.config(config)
prodBuilder.build('rxjs/Rx', path.resolve(__dirname, 'dist/cjs/bundles/Rx.min.js'), {sourceMaps: true, minify: true}).then(function() {
console.log('done with prod');
process.exit(0);
}, function(err) {
console.error('prod died', err);
process.exit(1);
});
}, function(err) {
console.log('dev died', err);
process.exit(1);
});
process.stdin.resume();