Angular-CLI-Based-Template: It seems that it compiles all TS files for Platform Server #289

Closed
opened 2025-08-09 17:15:43 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @naveedahmed1 on 12/5/2017

@SteveSandersonMS It seems that the new Angular CLI based template always compiles all TS files for Platform Server.

Angular CLI allows multiple apps to exists in same project through apps array, and usually we don't enable SSR for our complete application rather its mostly enabled for the portion that is safe to run on server side and usually for the sections that are the entry points for users.

If we look at apps array in .angular-cli it has two apps one for the client app and other for ssr. For app ssr we have "tsconfig": "tsconfig.app-ssr.json", and "main": "main.server.ts",

So as per my understanding, while building server bundles it should start from AppServerModule and recursively process files referenced in this module.

But it seems that it always compiles all files for platform server. Which breaks the app when we debug, and throws error like this.:

NodeInvocationException: Prerendering failed because of error: D:\MyProject\ClientApp\node_modules\ng2-img-cropper\src\imageCropperComponent.js:1
(function (exports, require, module, __filename, __dirname) { import { Component, Input, Renderer, ViewChild, Output, EventEmitter } from '@angular/core';

In this case I am using imageCropperComponent in BrowserAppModule only.

*Originally created by @naveedahmed1 on 12/5/2017* @SteveSandersonMS It seems that the new Angular CLI based template always compiles all TS files for Platform Server. Angular CLI allows multiple apps to exists in same project through `apps` array, and usually we don't enable SSR for our complete application rather its mostly enabled for the portion that is safe to run on server side and usually for the sections that are the entry points for users. If we look at `apps` array in `.angular-cli` it has two apps one for the client app and other for ssr. For app `ssr` we have `"tsconfig": "tsconfig.app-ssr.json",` and "main": "main.server.ts", So as per my understanding, while building server bundles it should start from `AppServerModule` and recursively process files referenced in this module. But it seems that it always compiles all files for platform server. Which breaks the app when we debug, and throws error like this.: ``` NodeInvocationException: Prerendering failed because of error: D:\MyProject\ClientApp\node_modules\ng2-img-cropper\src\imageCropperComponent.js:1 (function (exports, require, module, __filename, __dirname) { import { Component, Input, Renderer, ViewChild, Output, EventEmitter } from '@angular/core'; ``` In this case I am using `imageCropperComponent `in `BrowserAppModule` only.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#289
No description provided.