Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression problem in tsconfig.json outDir that cause VSCode showing errors in all import from libs pointed with paths under /dist/... #16708

Closed
1 of 15 tasks
dmorosinotto opened this issue Jan 19, 2020 · 2 comments · Fixed by #16709

Comments

@dmorosinotto
Copy link
Contributor

dmorosinotto commented Jan 19, 2020

🐞 Bug report

Command

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 8.3.23

Description

The root tsconfig.json used in the new v9.0.0-rc* template point "outDir": "./dist"
That caused annoying problem in VSCode when you rebuild libs referred by "paths"
all the code imports {...} from lib is marked as Errors by TS because they are build under /dist/...

🔬 Minimal Reproduction

Run those commands:

npx @angular/cli@next new --createApplication=false my-workspace

cd my-workspace
npm run ng -- generate library my-lib
npm run ng -- generate application my-app

The above commands are needed to setup the workspace for the repro with an application and a library pointed in the tsconfig.json "paths": { "my-lib": ["dist/my-lib"] }

then add this line to app.module.ts to use the library inside the application:

// app.module.ts
import { MyLibModule } from 'my-lib';

and then run the compilation of the my-lib project in watch mode:

npm run ng -- build project=my-lib --watch

You will see in VSCode that all imports pointing to the my-lib will be signal as TS Errors 2307

🔥 Exception or Error


Can't find module 'my-lib' ts(2307)

🌍 Your Environment


Angular CLI: 9.0.0-rc.9
Node: 12.14.1
OS: darwin x64

Angular: 9.0.0-rc.9
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.900.0-rc.9
@angular-devkit/build-angular      0.900.0-rc.9
@angular-devkit/build-ng-packagr   0.900.0-rc.9
@angular-devkit/build-optimizer    0.900.0-rc.9
@angular-devkit/build-webpack      0.900.0-rc.9
@angular-devkit/core               9.0.0-rc.9
@angular-devkit/schematics         9.0.0-rc.9
@ngtools/webpack                   9.0.0-rc.9
@schematics/angular                9.0.0-rc.9
@schematics/update                 0.900.0-rc.9
ng-packagr                         9.0.0-rc.7
rxjs                               6.5.4
typescript                         3.6.4
webpack                            4.41.2

Anything else relevant?
I tested this issue using VSCode and it is related to latest CLI v9.0.0-rc, but the same behaviour is CORRETLY WORKING without any issue in the previous CLI v8 (tested and works on ~8.2.23)

@damianog
Copy link

damianog commented Jan 19, 2020

Hi there, I've the same issue and made a video to clarify the repro

outDir

damianog referenced this issue Jan 19, 2020
Currently the library schematic doesn't support adding a secondary entry-point and having deep imports is not recommanded.

It's best if paths are more stricter when having a secondary entry-point instead of a wildcard.

Instead of :
```
"lib/*": [
  "dist/lib/*"
]
```

Users should configure:
```
"lib/secondary": [
  "dist/lib/secondary"
]
```

This would allow a better DX experience when using auto imports in IDE's.

Closes: #15952
dmorosinotto added a commit to dmorosinotto/angular-cli that referenced this issue Jan 19, 2020
Regression in tsconfig.json set `"outDir": "./dist/out-tsc"` for problems in VSCode TS(2307) when building library referred in tsconfig "paths" 
 
Closes: angular#16708
dmorosinotto added a commit to dmorosinotto/angular-cli that referenced this issue Jan 19, 2020
fix(@schematics/angular): regression tsconfig.json  …
Unverified
0e318ae
Regression in tsconfig.json set `"outDir": "./dist/out-tsc"` for problems in VSCode TS(2307) when building library referred in tsconfig "paths" 
 
Closes: angular#16708
@ngbot ngbot bot modified the milestone: Backlog Jan 20, 2020
@dmorosinotto dmorosinotto changed the title Regression problem in tsconfig.json outDir that cause VSCode showing errors in all import form libs poited with paths under /dist/... Regression problem in tsconfig.json outDir that cause VSCode showing errors in all import from libs pointed with paths under /dist/... Jan 22, 2020
kyliau pushed a commit that referenced this issue Jan 24, 2020
* fix(@schematics/angular): regression tsconfig.json

fix(@schematics/angular): regression tsconfig.json  …
Unverified
0e318ae
Regression in tsconfig.json set `"outDir": "./dist/out-tsc"` for problems in VSCode TS(2307) when building library referred in tsconfig "paths" 
 
Closes: #16708

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.

Closes #16709

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.
Fix code lint.

Closes #16709

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.
Fix test code to conform new behaviour.

Closes #16709
kyliau pushed a commit that referenced this issue Jan 24, 2020
* fix(@schematics/angular): regression tsconfig.json

fix(@schematics/angular): regression tsconfig.json  …
Unverified
0e318ae
Regression in tsconfig.json set `"outDir": "./dist/out-tsc"` for problems in VSCode TS(2307) when building library referred in tsconfig "paths"

Closes: #16708

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.

Closes #16709

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.
Fix code lint.

Closes #16709

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.
Fix test code to conform new behaviour.

Closes #16709

(cherry picked from commit 3aacf41)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants