Skip to content

Commit e4b51fc

Browse files
committed
Resolve some issues which prevented the CLI app from working properly on new "ng new" projects
1 parent cb43a41 commit e4b51fc

File tree

10 files changed

+37
-16
lines changed

10 files changed

+37
-16
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ node_modules
44

55
yarn-error.log
66

7+
nohup.out
8+
79
**/*.orig
810
**/*.rej
911

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ssr",
3-
"version": "0.0.0",
3+
"version": "0.0.5",
44
"description": "Angular server-side rendering implementation",
55
"main": "build/index.js",
66
"typings": "build/index.d.ts",
@@ -48,9 +48,9 @@
4848
"@angular/platform-browser": ">=2.3.1 <4.0.0",
4949
"@angular/router": ">=3.4 <4.0.0",
5050
"@angular/tsc-wrapped": ">=0.5 <1.0.0",
51-
"reflect-metadata": "^0.1",
51+
"reflect-metadata": ">0.0.0",
5252
"zone.js": "^0.7",
53-
"typescript": "^2.2.0"
53+
"typescript": "~2.0.0"
5454
},
5555
"optionalPeerDependencies": {
5656
"@ngrx/store": "^2.2.1"
@@ -73,7 +73,7 @@
7373
"rxjs": "5.1.0",
7474
"scoped-logger": "^0.0.19",
7575
"source-map-support": "0.4.11",
76-
"typescript": "2.2.0"
76+
"typescript": "~2.2.0"
7777
},
7878
"devDependencies": {
7979
"@angular/common": ">=2.3.1 <4.0.0",
@@ -123,5 +123,8 @@
123123
"source",
124124
"tsconfig.json",
125125
"tslint.json"
126-
]
126+
],
127+
"publishConfig": {
128+
"registry": "http://localhost:4873/"
129+
}
127130
}

source/application/compiler/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ApplicationBuild implements Disposable {
1515
return;
1616
}
1717

18-
for (const sourceFile of sourceFiles) {
18+
for (const sourceFile of sourceFiles.filter(sf => sf != null)) {
1919
const array = this.sourceArray(sourceFile.fileName);
2020
array.push(filename);
2121
}

source/application/compiler/factory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export const getCompilableProgram = (project: Project): CompilableProgram => {
1717

1818
const {parsed, ngOptions} = tsc.readConfiguration(project.tsconfig, project.basePath);
1919

20+
parsed.options.declaration = true;
21+
22+
ngOptions.declaration = true;
2023
ngOptions.basePath = project.basePath;
2124
ngOptions.generateCodeForLibraries = true;
2225

@@ -35,7 +38,7 @@ export const getCompilableProgram = (project: Project): CompilableProgram => {
3538

3639
export const adjustOptions = (baseOptions?: CompilerOptions): CompilerOptions => {
3740
return Object.assign({}, baseOptions, {
38-
declaration: false,
41+
declaration: true,
3942
module: ModuleKind.CommonJS,
4043
moduleResolution: ModuleResolutionKind.NodeJs,
4144
noEmitHelpers: false,

source/bin/options.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ export const commandLineToOptions = (): CommandLineOptions => {
4949
throw new ConfigurationException(`HTML template document does not exist: ${options['template']}`);
5050
}
5151

52-
const output = pathFromString(options['output']);
52+
let outputString = options['output'];
53+
54+
if (/^(\\|\/)/.test(outputString) === false) {
55+
outputString = join(process.cwd(), outputString);
56+
}
57+
58+
const output = pathFromString(outputString);
5359

5460
return {output, project, templateDocument: template.content()};
5561
};

source/bin/render.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'reflect-metadata';
2+
13
import '../dependencies';
24

35
import {ApplicationRenderer, ApplicationFromSource} from '../application';

source/dependencies.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import 'reflect-metadata';
2-
31
import 'zone.js/dist/zone-node';
42
import 'zone.js/dist/long-stack-trace-zone';
53

6-
import './runtime';
4+
import './runtime';

source/exception.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import {EOL} from 'os';
22

33
export class Exception extends Error {
44
constructor(msg: string, public innerException?: Error) {
5-
super(innerException ? `${msg} -> ${innerException.toString()}` : msg);
5+
super(innerException ? `${msg} -> ${innerException.stack}` : msg);
66
}
77
}
88

99
export class AggregateException extends Exception {
1010
constructor(public exceptions: Array<Exception | Error>) {
11-
super(`Multiple exceptions occurred (${exceptions.length}) [${exceptions.map(e => e.toString()).join(', ')}]`);
11+
super(`Multiple exceptions occurred (${exceptions.length}) [${exceptions.map(e => e.stack).join(', ')}]`);
1212
}
1313

1414
get stack(): string {

source/platform/location/location.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'reflect-metadata';
2-
31
import {
42
Inject,
53
Injectable,

source/transpile/transpilers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ export const transformRequires = (source: string): string =>
6464
export const transformImports = (source: string): string =>
6565
source.replace(/from ['"]@angular\/([^\/'"]+)['"]/g, 'from "@angular/$1/index"');
6666

67-
export const debundleImport = (moduleId: string): string => moduleId.replace(/@angular\/([^\/]+)$/, '@angular/$1/index');
67+
export const debundleImport = (moduleId: string): string => {
68+
if (moduleId.endsWith('.js')) {
69+
return moduleId.replace(/@angular\/([^\/]+)\/bundles\/([^\/]+).umd.js/, '@angular/$1/index.js');
70+
}
71+
return moduleId.replace(/@angular\/([^\/]+)$/, '@angular/$1/index');
72+
};
6873

6974
export const transpile = (transpilers: Array<TranspileDescriptor>, module: NodeModule, basePath?: string): string => {
7075
for (const transpiler of transpilers) {
@@ -78,6 +83,10 @@ export const transpile = (transpilers: Array<TranspileDescriptor>, module: NodeM
7883
}
7984
}
8085

86+
if (transpiler.moduleTranslator) {
87+
module.filename = require.resolve(transpiler.moduleTranslator(module.id || module.filename));
88+
}
89+
8190
const file = fileFromString(module.filename);
8291

8392
const content = file.content();

0 commit comments

Comments
 (0)