1
1
import { normalize } from 'path' ;
2
2
import { getGlobalVariable } from '../../utils/env' ;
3
- import { expectFileToMatch , writeFile } from '../../utils/fs' ;
3
+ import { expectFileToMatch , writeFile , appendToFile } from '../../utils/fs' ;
4
4
import { exec , ng , silentNpm } from '../../utils/process' ;
5
5
import { updateJsonFile } from '../../utils/project' ;
6
6
import { readNgVersion } from '../../utils/version' ;
@@ -21,15 +21,16 @@ export default async function () {
21
21
} ) ;
22
22
23
23
await silentNpm ( 'install' ) ;
24
- await ng ( 'run' , 'test-project:server:production' ) ;
25
- await expectFileToMatch ( 'dist/server/main.js' , / e x p o r t s .* A p p S e r v e r M o d u l e N g F a c t o r y / ) ;
24
+ await appendToFile (
25
+ 'src/main.server.ts' ,
26
+ `export { renderModuleFactory } from '@angular/platform-server';` ,
27
+ ) ;
26
28
27
29
await writeFile (
28
30
'./index.js' ,
29
31
` require('zone.js/dist/zone-node');
30
32
const fs = require('fs');
31
- const { AppServerModuleNgFactory } = require('./dist/server/main');
32
- const { renderModuleFactory } = require('@angular/platform-server');
33
+ const { AppServerModuleNgFactory, renderModuleFactory } = require('./dist/server/main');
33
34
34
35
renderModuleFactory(AppServerModuleNgFactory, {
35
36
url: '/',
@@ -40,6 +41,16 @@ export default async function () {
40
41
` ,
41
42
) ;
42
43
44
+ await ng ( 'run' , 'test-project:server:production' ) ;
45
+ await expectFileToMatch ( 'dist/server/main.js' , / e x p o r t s .* A p p S e r v e r M o d u l e N g F a c t o r y / ) ;
46
+ await exec ( normalize ( 'node' ) , 'index.js' ) ;
47
+ await expectFileToMatch (
48
+ 'dist/server/index.html' ,
49
+ / < p .* > H e r e a r e s o m e l i n k s t o h e l p y o u g e t s t a r t e d : < \/ p > / ,
50
+ ) ;
51
+
52
+ // works with optimization and bundleDependencies enabled
53
+ await ng ( 'run' , 'test-project:server:production' , '--optimization' , '--bundleDependencies' , 'all' ) ;
43
54
await exec ( normalize ( 'node' ) , 'index.js' ) ;
44
55
await expectFileToMatch (
45
56
'dist/server/index.html' ,
0 commit comments