11import { normalize } from 'path' ;
22import { getGlobalVariable } from '../../utils/env' ;
3- import { expectFileToMatch , writeFile } from '../../utils/fs' ;
3+ import { expectFileToMatch , writeFile , appendToFile } from '../../utils/fs' ;
44import { exec , ng , silentNpm } from '../../utils/process' ;
55import { updateJsonFile } from '../../utils/project' ;
66import { readNgVersion } from '../../utils/version' ;
@@ -21,15 +21,16 @@ export default async function () {
2121 } ) ;
2222
2323 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+ ) ;
2628
2729 await writeFile (
2830 './index.js' ,
2931 ` require('zone.js/dist/zone-node');
3032 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');
3334
3435 renderModuleFactory(AppServerModuleNgFactory, {
3536 url: '/',
@@ -40,6 +41,16 @@ export default async function () {
4041 ` ,
4142 ) ;
4243
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' ) ;
4354 await exec ( normalize ( 'node' ) , 'index.js' ) ;
4455 await expectFileToMatch (
4556 'dist/server/index.html' ,
0 commit comments