Skip to content

prod build fails, file missing in typeScript compilation even so it's there, normal build works #13592

@judos

Description

@judos

🐞 Bug report

Command (mark with an x)

- [x] build
- [x] serve

Description

"ng build" works, but "ng build --prod" throws error about missing file.
When I disable aot in angular.json / production configuration the error doesn't occur

In tsconfig.app.json I tried to include that file with 'include' or 'files' and many different paths (./app app/ src/app/) but that doesn't help.

🔥 Exception or Error

ERROR in ./src/app/model/generated-dto.d.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: D:\projects\eclipse\x2\x-frontend\src\app\model\generated-dto.d.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (D:\projects\eclipse\x2\x-frontend\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:752:23)
    at plugin.done.then (D:\projects\eclipse\x2\x-frontend\node_modules\@ngtools\webpack\src\loader.js:41:31)
    at 
    at process._tickCallback (internal/process/next_tick.js:188:7)

🌍 Your Environment


Angular CLI: 6.2.9
Node: 8.11.2
OS: win32 x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.0
@angular-devkit/build-angular     0.13.0
@angular-devkit/build-optimizer   0.13.0
@angular-devkit/build-webpack     0.13.0
@angular-devkit/core              7.3.0
@angular-devkit/schematics        0.8.9
@angular/cli                      6.2.9
@ngtools/webpack                  7.3.0
@schematics/angular               0.8.9
@schematics/update                0.8.9
rxjs                              6.0.0
typescript                        2.9.2
webpack                           4.29.0

Anything else relevant?

I read about everything on stackoverflow and github issues but didn't find anything that fixes the error.
A few relevant files of our project:
tsconfig.app.json


{
	"extends": "../tsconfig.json",
	"compilerOptions": {
		"outDir": "../out-tsc/app",
		"module": "es2015",
		"types": []
	},
	"exclude": [
		"test.ts",
		"**/*.spec.ts"
	],
	"include": [
		"app/model/generated-dto.d.ts",
		"main.ts",
		"polyfills.ts"
	]
}

tsconfig.json


{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

angular.json


{
	"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
	"version": 1,
	"newProjectRoot": "projects",
	"projects": {
		"x-frontend": {
			"root": "",
			"sourceRoot": "src",
			"projectType": "application",
			"prefix": "app",
			"schematics": {
				
			},
			"architect": {
				"build": {
					"builder": "@angular-devkit/build-angular:browser",
					"options": {
						"outputPath": "dist/x-frontend",
						"index": "src/index.html",
						"main": "src/main.ts",
						"polyfills": "src/polyfills.ts",
						"tsConfig": "src/tsconfig.app.json",
						"assets": [
							"src/assets"
						],
						"styles": [
							"node_modules/bootstrap/dist/css/bootstrap.min.css",
							"node_modules/@fortawesome/fontawesome-free/css/all.css"
						],
						"scripts": []
					},
					"configurations": {
						"production": {
							"fileReplacements": [
								{
									"replace": "src/environments/environment.ts",
									"with": "src/environments/environment.prod.ts"
								}
							],
							"optimization": true,
							"outputHashing": "all",
							"sourceMap": false,
							"extractCss": true,
							"namedChunks": false,
							"extractLicenses": true,
							"vendorChunk": false,
							
							"aot": true,
							"buildOptimizer": false
						}
					}
				},
				"serve": {
					"builder": "@angular-devkit/build-angular:dev-server",
					"options": {
						"browserTarget": "x-frontend:build"
					},
					"configurations": {
						"production": {
							"browserTarget": "x-frontend:build:production"
						}
					}
				},
				"extract-i18n": {
					"builder": "@angular-devkit/build-angular:extract-i18n",
					"options": {
						"browserTarget": "x-frontend:build"
					}
				},
				"test": {
					"builder": "@angular-devkit/build-angular:karma",
					"options": {
						"main": "src/test.ts",
						"polyfills": "src/polyfills.ts",
						"tsConfig": "src/tsconfig.spec.json",
						"karmaConfig": "src/karma.conf.js",
						"styles": [],
						"scripts": [],
						"assets": [
							"src/assets"
						]
					}
				},
				"lint": {
					"builder": "@angular-devkit/build-angular:tslint",
					"options": {
						"tsConfig": [
							"src/tsconfig.app.json",
							"src/tsconfig.spec.json"
						],
						"exclude": [
							"**/node_modules/**"
						]
					}
				}
			}
		},
		"x-frontend-e2e": {
			"root": "e2e/",
			"projectType": "application",
			"architect": {
				"e2e": {
					"builder": "@angular-devkit/build-angular:protractor",
					"options": {
						"protractorConfig": "e2e/protractor.conf.js",
						"devServerTarget": "x-frontend:serve"
					}
				},
				"lint": {
					"builder": "@angular-devkit/build-angular:tslint",
					"options": {
						"tsConfig": "e2e/tsconfig.e2e.json",
						"exclude": [
							"**/node_modules/**"
						]
					}
				}
			}
		}
	},
	"defaultProject": "x-frontend"
}

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions