Skip to content

Commit 3e0a27d

Browse files
committed
feat(build): system.js bundles replaced with UMD bundles
BREAKIN CHANGES: - please read sample repo readme.md to update you system.js config https://github.com/valor-software/angular2-quickstart
1 parent a7554a8 commit 3e0a27d

File tree

4 files changed

+91
-152
lines changed

4 files changed

+91
-152
lines changed

.config/bundle-system.js

Lines changed: 0 additions & 113 deletions
This file was deleted.

.config/umd-bundler.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
/*eslint no-console: 0, no-sync: 0*/
6+
7+
// UMD bundler
8+
// simple and yet reusable system.js bundler
9+
// bundles, minifies and gzips
10+
11+
const fs = require('fs');
12+
const del = require('del');
13+
const path = require('path');
14+
const zlib = require('zlib');
15+
const async = require('async');
16+
const Builder = require('systemjs-builder');
17+
18+
const pkg = require('../package.json');
19+
const name = pkg.name;
20+
const targetFolder = path.resolve('./bundles');
21+
22+
async.waterfall([
23+
cleanBundlesFolder,
24+
getSystemJsBundleConfig,
25+
buildSystemJs({minify: false, sourceMaps: true, mangle: false, noEmitHelpers: false, declaration: true}),
26+
getSystemJsBundleConfig,
27+
buildSystemJs({minify: true, sourceMaps: true, mangle: false, noEmitHelpers: false, declaration: true})
28+
], err => {
29+
if (err) {
30+
throw err;
31+
}
32+
});
33+
34+
function getSystemJsBundleConfig(cb) {
35+
const config = {
36+
baseURL: '.',
37+
transpiler: 'typescript',
38+
typescriptOptions: {
39+
module: 'cjs'
40+
},
41+
map: {
42+
typescript: './node_modules/typescript/lib/typescript',
43+
'@angular': './node_modules/@angular',
44+
rxjs: './node_modules/rxjs'
45+
},
46+
paths: {
47+
'*': '*.js'
48+
},
49+
meta: {
50+
'./node_modules/@angular/*': {build: false},
51+
'./node_modules/rxjs/*': {build: false},
52+
moment: {build: false}
53+
}
54+
};
55+
56+
return cb(null, config);
57+
}
58+
59+
function cleanBundlesFolder(cb) {
60+
return del(targetFolder)
61+
.then(paths => {
62+
console.log('Deleted files and folders:\n', paths.join('\n'));
63+
cb();
64+
});
65+
}
66+
67+
function buildSystemJs(options) {
68+
return (config, cb) => {
69+
const minPostFix = options && options.minify ? '.umd.min' : '.umd';
70+
const fileName = `${name}${minPostFix}.js`;
71+
const dest = path.resolve(__dirname, targetFolder, fileName);
72+
const builder = new Builder();
73+
74+
console.log('Bundling system.js file:', fileName, options);
75+
builder.config(config);
76+
77+
return builder
78+
.buildStatic(name, dest, {format: 'umd'})
79+
.then(() => {
80+
console.log('Build complete.');
81+
cb();
82+
})
83+
.catch(err => {
84+
console.log('Error', err);
85+
cb();
86+
});
87+
};
88+
}

make.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"flow.docs": "npm run typedoc -- --exclude '**/*.spec.ts' ./components/",
88
"flow.compile": "npm run flow.compile:common && npm run flow.compile:system",
99
"flow.compile:common": "ngc -p tsconfig.publish.json",
10-
"flow.compile:system": "node ./.config/bundle-system.js",
10+
"flow.compile:system": "node .config/umd-bundler.js",
1111
"flow.copy:src": "cpy ng2-bootstrap.ts \"components/*.ts\" ts --parents",
1212
"flow.clean": "del-cli bundles coverage demo-build \"components/**/*.+(js|d.ts|js.map|metadata.json)\" dist \"ng2-bootstrap.+(js|d.ts|js.map|metadata.json)\" factories",
1313
"flow.deploy:gh-pages": "npm run flow.build:prod && gh-pages -d demo-build",
@@ -30,7 +30,8 @@
3030
"version": "npm run flow.changelog && git add -A",
3131
"postversion": "git push origin development && git push --tags"
3232
},
33-
"main": "ng2-bootstrap.js",
33+
"main": "bundles/ng2-bootstrap.js",
34+
"module": "ng2-bootstrap.js",
3435
"typings": "ng2-bootstrap.d.ts",
3536
"keywords": [
3637
"angular2",

0 commit comments

Comments
 (0)