Skip to content

Commit 8240e19

Browse files
committed
Describe common error that happens with AoT loader
1 parent 156c45f commit 8240e19

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- [On-demand rendering using express](#on-demand-rendering-using-express)
3737
- [On-demand rendering using koa](#on-demand-rendering-using-koa)
3838
- [FAQ](#faq)
39+
- [Troubleshooting](#troubleshooting)
3940
- [Comments, queries, or rants](#comments-queries-or-rants)
4041

4142
# Introduction
@@ -619,6 +620,34 @@ A project using koa and `angular-ssr` lives in the [`examples/demand-koa`](https
619620
* The `angular-ssr` package will be split into `@angular-ssr/server`, `@angular-ssr/client` and a couple other packages. This will allow us to build some cool client-side features that will integrate with the server-side rendering functionality.
620621
* As `@angular/platform-server` fills out and matures, `angular-ssr` will eventually become obsolete. The Angular team is working on a lot of great features (with some inspiration from `angular-ssr` -- for instance, a real DOM implementation!). These changes will ultimately make `angular-ssr` redundant. But the cost of transitioning from `angular-ssr` to `platform-server` will be minimal because the API surface of both libraries are tiny. So I would recommend using `angular-ssr` today and upgrading to `platform-server` in the next 6 months or a year or so.
621622

623+
# Troubleshooting
624+
625+
If you are using `ng-render` and your build fails with this error:
626+
627+
```
628+
ERROR in ./src/app/app.module.ts
629+
Module build failed: TypeError: Cannot read property 'newLine' of undefined
630+
at Object.getNewLineCharacter (/home/bond/project/node_modules/typescript/lib/typescript.js:9514:20)
631+
at Object.createCompilerHost (/home/bond/project/node_modules/typescript/lib/typescript.js:63770:26)
632+
at Object.ngcLoader (/home/bond/project/node_modules/@ngtools/webpack/src/loader.js:380:33)
633+
@ multi ./app/app.module.ts
634+
```
635+
636+
This is because you are attempting to use the AoT loader, `@ngtools/webpack`, with `ng-render`. Please do not do this. You should only be using `@ngtools/webpack` for production AoT builds, not `ng-render` builds. Therefore in your `webpack.config.js`, only enable the AoT loader in production mode:
637+
638+
```
639+
const production = !process.env.NG_RENDER && process.env.NODE_ENV === 'production';
640+
```
641+
642+
Then in the loader chain description for TypeScript files:
643+
644+
```
645+
{
646+
test: /\.ts$/,
647+
use: production ? ['@ngtools/webpack'] : ['ts-helper', 'angular2-template-loader', 'angular-router-loader']
648+
}
649+
```
650+
622651
# Comments, queries, or rants
623652

624653
Direct your vitriol to cb@clbond.org or post an issue on this GitHub repo!

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ssr",
3-
"version": "0.10.16",
3+
"version": "0.10.17",
44
"description": "Angular server-side rendering implementation",
55
"main": "build/index.js",
66
"typings": "build/index.d.ts",

0 commit comments

Comments
 (0)