|
1 | 1 | import { normalize } from 'path';
|
2 | 2 |
|
3 | 3 | import { updateJsonFile, updateTsConfig } from '../../utils/project';
|
4 |
| -import { expectFileToMatch, writeFile, replaceInFile, prependToFile } from '../../utils/fs'; |
| 4 | +import { |
| 5 | + expectFileToMatch, |
| 6 | + writeFile, |
| 7 | + replaceInFile, |
| 8 | + prependToFile, |
| 9 | + appendToFile, |
| 10 | +} from '../../utils/fs'; |
5 | 11 | import { ng, silentNpm, exec } from '../../utils/process';
|
6 | 12 | import { getGlobalVariable } from '../../utils/env';
|
| 13 | +import { expectToFail } from '../../utils/utils'; |
7 | 14 |
|
8 | 15 | export default function () {
|
9 | 16 | // Skip this in Appveyor tests.
|
@@ -34,6 +41,7 @@ export default function () {
|
34 | 41 | dependencies['@angular/platform-server'] = platformServerVersion;
|
35 | 42 | }))
|
36 | 43 | .then(() => updateTsConfig(tsConfig => {
|
| 44 | + tsConfig.compilerOptions.types = ['node']; |
37 | 45 | tsConfig['angularCompilerOptions'] = {
|
38 | 46 | entryModule: 'app/app.module#AppModule'
|
39 | 47 | };
|
@@ -73,5 +81,28 @@ export default function () {
|
73 | 81 | .then(() => replaceInFile('./index.js', /renderModule/g, 'renderModuleFactory'))
|
74 | 82 | .then(() => exec(normalize('node'), 'index.js'))
|
75 | 83 | .then(() => expectFileToMatch('dist/index.html',
|
76 |
| - new RegExp('<h2 _ngcontent-c0="">Here are some links to help you start: </h2>'))); |
| 84 | + new RegExp('<h2 _ngcontent-c0="">Here are some links to help you start: </h2>'))) |
| 85 | + .then(() => expectFileToMatch('./dist/main.bundle.js', |
| 86 | + /require\(["']@angular\/[^"']*["']\)/)) |
| 87 | + |
| 88 | + // Check externals. |
| 89 | + .then(() => prependToFile('./src/app/app.module.ts', ` |
| 90 | + import 'zone.js/dist/zone-node'; |
| 91 | + import 'reflect-metadata'; |
| 92 | + `) |
| 93 | + .then(() => appendToFile('./src/app/app.module.ts', ` |
| 94 | + import * as fs from 'fs'; |
| 95 | + import { renderModule } from '@angular/platform-server'; |
| 96 | +
|
| 97 | + renderModule(AppModule, \{ |
| 98 | + url: '/', |
| 99 | + document: '<app-root></app-root>' |
| 100 | + \}).then(html => \{ |
| 101 | + fs.writeFileSync('dist/index.html', html); |
| 102 | + \}); |
| 103 | + `))) |
| 104 | + .then(() => ng('build', '--bundle-dependencies=all')) |
| 105 | + .then(() => expectToFail(() => expectFileToMatch('./dist/main.bundle.js', |
| 106 | + /require\(["']@angular\/[^"']*["']\)/))) |
| 107 | + .then(() => exec(normalize('node'), 'dist/main.bundle.js')); |
77 | 108 | }
|
0 commit comments