nx: ssr doesn't recognize lib shortnames in tsconfig
Have an angular universal app where bundling to prod works fine for import statements with @lib, but getting the error
Could not resolve @workpace/mylib-name relative to /Users/me/folder/workspace/apps/app-name/src/app/app.module.ts
Is there a way to do this, or do I need to turn library @names into relative paths?
Seems like the server side rendering isn’t able to pull the paths from tsconfig
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 16 (6 by maintainers)
What a coincidence, just ran into this today.
It’s an issue with the schematic that gets generated. Make sure you remove the baseUrl property in the
tsconfig.server.jsonand extend either off of thetsconfig.app.jsonor the roottsconfig.json.So the workaround is manually reconfiguring it. Let’s also leave this issue open to track resolution of the issue.
I stumbled on this ticket cause I had a similar issue when trying to pre-render my application and compiling the server with Webpack, as per the CLI’s Universal story, due to Webpack not being able to resolve the
pathsconfig from thetsconfig.jsonfile. Since this ticket it’s related to SSR and other people might also stumble on this, I thought I might share that, to solve this, you can useTsconfigPathsPluginfrom tsconfig-paths-webpack-plugin and use it on yourwebpack.config.jslike this:@FrozenPandaz can you take a look?
no worries, happy to help! I’ll add some comments to the PR to explain a bit some of the changes 😃
@FrozenPandaz Thank you very much for your advice. I was having problems because of that baseurl and I didn’t know. Anyway I had to use @hmagrini solution as well.
@hmagrini Thank you very much for it. Using the TsconfigPathsPlugin I was able to fix my issue.