Description
🐞 Bug report
Command (mark with an x
)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [x] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
no
Description
running ng add @nguniversal/express-engine --clientProject projectName
generates tsconfig.server.json
which has "baseUrl": "."
that broke the paths
from the parent tsconfig.json
the paths
option is used when generating a library so that the project reads the complied code from dist and works normally
🔬 Minimal Reproduction
Reproduction repo
https://github.com/robertIsaac/ng-lib-ssr
generated as followed
ng new lib-ssr // commit #1 initial commit
cd lib-ssr // works fine from localhost:4200
ng add @nguniversal/express-engine --clientProject lib-ssr // commit #2 add ssr
npm run build:ssr && npm run serve:ssr // works fine from localhost:4000
ng g library lib // commit #3 add lib
ng b lib // build the library to start using it
// import LibModule from app.module and use <lib-lib> compoennt in app.compoennt
// commit #4 "use lib component inside the project"
npm start // works fine from lcoalhost:4200 and shows "lib works!"
npm run build:ssr && npm run serve:ssr or just ng run lib-ssr:server:production // will throw the error
🔥 Exception or Error
ERROR in src\app\app.module.ts(13,5): Error during template compile of 'AppModule'
Could not resolve lib relative to [object Object]..
src/app/app.module.ts(5,25): error TS2307: Cannot find module 'lib'.
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 7.3.6
Node: 11.11.0
OS: win32 x64
Angular: 7.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.13.6
@angular-devkit/build-angular 0.13.6
@angular-devkit/build-ng-packagr 0.13.6
@angular-devkit/build-optimizer 0.13.6
@angular-devkit/build-webpack 0.13.6
@angular-devkit/core 7.3.6
@angular-devkit/schematics 7.3.6
@angular/cli 7.3.6
@ngtools/json-schema 1.1.0
@ngtools/webpack 7.3.6
@schematics/angular 7.3.6
@schematics/update 0.13.6
ng-packagr 4.7.1
rxjs 6.3.3
typescript 3.2.4
webpack 4.29.0
Anything else relevant?
solving the problem is to edit src/tsconfig.server.json
and remove "baseUrl": "."
from compilerOptions
or add
"paths": {
"lib": [
"../dist/lib"
],
"lib/*": [
"../dist/lib/*"
]
}
to the compilerOptions
but the latter refer to lib-ssr/out-tsc
as tsc output so you may consider changing the outDir
to ../dist/out-tsc/app-server
so that it refer lib-ssr/dist/out-tsc
as it suppose to but i'm not sure if it will matter at all