Skip to content

Commit 4a0209c

Browse files
committed
fix: ignore traceur and ngc bundles
1 parent 86663d4 commit 4a0209c

File tree

4 files changed

+138
-33
lines changed

4 files changed

+138
-33
lines changed

tools/config/seed.config.ts

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -382,38 +382,70 @@ export class SeedConfig {
382382
SYSTEM_BUILDER_CONFIG: any = {
383383
defaultJSExtensions: true,
384384
base: this.PROJECT_ROOT,
385+
packageConfigPaths: [
386+
join(this.PROJECT_ROOT, 'node_modules', '*', 'package.json'),
387+
join(this.PROJECT_ROOT, 'node_modules', '@ngrx', '*', 'package.json'),
388+
join(this.PROJECT_ROOT, 'node_modules', '@angular', '*', 'package.json')
389+
],
385390
paths: {
386391
// Note that for multiple apps this configuration need to be updated
387392
// You will have to include entries for each individual application in
388393
// `src/client`.
389394
[join(this.TMP_DIR, this.BOOTSTRAP_DIR, '*')]: `${this.TMP_DIR}/${this.BOOTSTRAP_DIR}/*`,
390395
'dist/tmp/node_modules/*': 'dist/tmp/node_modules/*',
391-
'@angular/common': 'node_modules/@angular/common/bundles/common.umd.js',
392-
'@angular/compiler': 'node_modules/@angular/compiler/bundles/compiler.umd.js',
393-
'@angular/core': 'node_modules/@angular/core/bundles/core.umd.js',
394-
'@angular/forms': 'node_modules/@angular/forms/bundles/forms.umd.js',
395-
'@angular/http': 'node_modules/@angular/http/bundles/http.umd.js',
396-
'@angular/platform-browser': 'node_modules/@angular/platform-browser/bundles/platform-browser.umd.js',
397-
'@angular/platform-browser-dynamic': 'node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
398-
'@angular/router': 'node_modules/@angular/router/bundles/router.umd.js',
399-
400-
'@angular/common/testing': 'node_modules/@angular/common/bundles/common-testing.umd.js',
401-
'@angular/compiler/testing': 'node_modules/@angular/compiler/bundles/compiler-testing.umd.js',
402-
'@angular/core/testing': 'node_modules/@angular/core/bundles/core-testing.umd.js',
403-
'@angular/http/testing': 'node_modules/@angular/http/bundles/http-testing.umd.js',
404-
'@angular/platform-browser/testing':
405-
'node_modules/@angular/platform-browser/bundles/platform-browser-testing.umd.js',
406-
'@angular/platform-browser-dynamic/testing':
407-
'node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
408-
'@angular/router/testing': 'node_modules/@angular/router/bundles/router-testing.umd.js',
409-
410396
'node_modules/*': 'node_modules/*',
411397
'*': 'node_modules/*'
412398
},
399+
meta: {
400+
'*.json': {
401+
format: 'json'
402+
}
403+
},
413404
packages: {
405+
'@angular/core': {
406+
main: 'index.js',
407+
defaultExtension: 'js'
408+
},
409+
'@angular/compiler': {
410+
main: 'index.js',
411+
defaultExtension: 'js'
412+
},
413+
'@angular/common': {
414+
main: 'index.js',
415+
defaultExtension: 'js'
416+
},
417+
'@angular/http': {
418+
main: 'index.js',
419+
defaultExtension: 'js'
420+
},
421+
'@angular/platform-browser': {
422+
main: 'index.js',
423+
defaultExtension: 'js'
424+
},
425+
'@angular/platform-browser-dynamic': {
426+
main: 'index.js',
427+
defaultExtension: 'js'
428+
},
429+
'@angular/router-deprecated': {
430+
main: 'index.js',
431+
defaultExtension: 'js'
432+
},
433+
'@angular/router': {
434+
main: 'index.js',
435+
defaultExtension: 'js'
436+
},
437+
'@angular/forms': {
438+
main: 'index.js',
439+
defaultExtension: 'js'
440+
},
414441
'rxjs': {
415442
main: 'Rx.js',
416443
defaultExtension: 'js'
444+
},
445+
'jstimezonedetect': {
446+
main: 'dist/jstz.min.js',
447+
format: 'cjs',
448+
defaultExtension: 'js'
417449
}
418450
}
419451
};
@@ -620,3 +652,4 @@ function getBuildType() {
620652
return BUILD_TYPES.DEVELOPMENT;
621653
}
622654
}
655+

tools/tasks/seed/build.lazy-bundles.app.exp.ts

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Config from '../../config';
66

77
const BUNDLER_OPTIONS = {
88
format: 'cjs',
9-
minify: true,
9+
minify: false,
1010
mangle: false
1111
};
1212

@@ -21,23 +21,78 @@ const normalizeConfig = (bundles: any[]) => {
2121
b = { path: b };
2222
}
2323
if (!b.module) {
24-
b.module = b.path.split('\/').pop() + '.module.js';
24+
b.module = b.path.split('\/').pop() + '.module.ngfactory.js';
2525
} else {
26-
b.module += '.js';
26+
b.module += '.ngfactory.js';
2727
}
2828
return b;
2929
});
3030
};
3131

3232
const addExtensions = `
33-
System.config({ defaultJSExtensions: true });
34-
(function () {
35-
Object.keys(System.defined).forEach(function (m) {
36-
if (!/\.js$/.test(m)) {
37-
System.defined[m + '.js'] = System.defined[m];
33+
$traceurRuntime = {
34+
typeof: function (a) {
35+
return typeof a;
36+
}
37+
};
38+
System.config({
39+
defaultJSExtensions: true,
40+
paths: {
41+
'rxjs/*': 'rxjs/*'
42+
},
43+
meta: {
44+
'*.json': {
45+
format: 'json'
3846
}
39-
});
40-
}());
47+
},
48+
packages: {
49+
'@angular/core': {
50+
main: 'index.js',
51+
defaultExtension: 'js'
52+
},
53+
'@angular/compiler': {
54+
main: 'index.js',
55+
defaultExtension: 'js'
56+
},
57+
'@angular/common': {
58+
main: 'index.js',
59+
defaultExtension: 'js'
60+
},
61+
'@angular/http': {
62+
main: 'index.js',
63+
defaultExtension: 'js'
64+
},
65+
'@angular/forms': {
66+
main: 'index.js',
67+
defaultExtension: 'js'
68+
},
69+
'@angular/platform-browser': {
70+
main: 'index.js',
71+
defaultExtension: 'js'
72+
},
73+
'@angular/platform-browser-dynamic': {
74+
main: 'index.js',
75+
defaultExtension: 'js'
76+
},
77+
'@angular/router-deprecated': {
78+
main: 'index.js',
79+
defaultExtension: 'js'
80+
},
81+
'@angular/router': {
82+
main: 'index.js',
83+
defaultExtension: 'js'
84+
},
85+
'jstimezonedetect': {
86+
main: 'dist/jstz.min.js',
87+
format: 'cjs',
88+
defaultExtension: 'js'
89+
},
90+
'rxjs': {
91+
main: 'Rx.js',
92+
defaultExtension: 'js'
93+
}
94+
}
95+
});
4196
`;
4297

4398
const bundleMain = () => {
@@ -47,9 +102,9 @@ const bundleMain = () => {
47102
return builder
48103
.bundle(mainpath,
49104
outpath,
50-
Object.assign({ format: 'umd', sourceMaps: true }, BUNDLER_OPTIONS))
105+
Object.assign({ format: 'umd', sourceMaps: true, runtime: true }, BUNDLER_OPTIONS))
51106
.then((res: any) => {
52-
appendFileSync(outpath, `System.import('${mainpath}.js');${addExtensions}`);
107+
appendFileSync(outpath, `\nSystem.import('${mainpath}.js');${addExtensions}`);
53108
return res.modules;
54109
});
55110
};
@@ -65,7 +120,7 @@ const bundleModule = (config: Bundle[], exclude: string[], bundle: Bundle) => {
65120
.buildStatic(
66121
expression,
67122
join(Config.JS_DEST, '..', Config.BOOTSTRAP_DIR, bundle.path, bundle.module),
68-
Object.assign({}, BUNDLER_OPTIONS, { format: 'umd', sourceMaps: true }))
123+
Object.assign({}, BUNDLER_OPTIONS, { format: 'umd', sourceMaps: true, runtime: true }))
69124
.then((res: any) => {
70125
console.log(res.modules);
71126
console.log('Bundled', bundle.path);
@@ -78,6 +133,7 @@ const bundleModule = (config: Bundle[], exclude: string[], bundle: Bundle) => {
78133
*/
79134
export = (done: any) => {
80135
const config = normalizeConfig(Config.BUNDLES);
136+
console.log(config);
81137
bundleMain()
82138
.then((bundled: string[]) => Promise.all(config.map(bundleModule.bind(null, config, bundled))))
83139
.then(() => done())

tools/tasks/seed/build.lazy-bundles.app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const bundleMain = () => {
4949
outpath,
5050
Object.assign({ format: 'umd', sourceMaps: true }, BUNDLER_OPTIONS))
5151
.then((res: any) => {
52-
appendFileSync(outpath, `System.import('${mainpath}.js');${addExtensions}`);
52+
appendFileSync(outpath, `\nSystem.import('${mainpath}.js');${addExtensions}`);
5353
return res.modules;
5454
});
5555
};

tools/tasks/seed/compile.ahead.prod.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ import { CodeGenerator } from '@angular/compiler-cli';
88

99
import Config from '../../config';
1010

11+
const normalizeConfig = (bundles: any[]) => {
12+
return bundles.map(b => {
13+
if (typeof b === 'string') {
14+
b = { path: b };
15+
}
16+
if (!b.module) {
17+
b.module = b.path.split('\/').pop() + '.module.ts';
18+
} else {
19+
b.module += '.ts';
20+
}
21+
return b;
22+
});
23+
};
24+
1125
function codegen(
1226
ngOptions: tsc.AngularCompilerOptions, cliOptions: tsc.NgcCliOptions, program: ts.Program,
1327
host: ts.CompilerHost) {
@@ -21,10 +35,12 @@ const modifyFile = (path: string, mod: any = (f: string) => f) => {
2135

2236
export = (done: any) => {
2337
// Note: dirty hack until we're able to set config easier
38+
const config = normalizeConfig(JSON.parse(JSON.stringify(Config.BUNDLES)));
2439
modifyFile(join(Config.TMP_DIR, 'tsconfig.json'), (content: string) => {
2540
const parsed = JSON.parse(content);
2641
parsed.files = parsed.files || [];
2742
parsed.files.push(join(Config.BOOTSTRAP_DIR, 'main.ts'));
43+
config.forEach((f: any) => parsed.files.push(join(Config.BOOTSTRAP_DIR, f.path, f.module)));
2844
return JSON.stringify(parsed, null, 2);
2945
});
3046
const args = argv;

0 commit comments

Comments
 (0)