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

tsc --watch is inconsistently reporting node_modules files as being outside rootDir #19327

Closed
Jessidhia opened this issue Oct 19, 2017 · 6 comments · Fixed by #19435
Closed
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@Jessidhia
Copy link

TypeScript Version: 2.6.0-rc

Code

With a directory layout like:

node_modules/
src/tsconfig.json
src/index.ts
package.json
import findCacheDir = require('find-cache-dir')

Expected behavior:

Compilation with no errors (other than findCacheDir not used if the option is enabled)

Actual behavior:

Intermittent error TS6059 whenever the file is edited. The error occasionally goes away or returns whenever a build is triggered by --watch.

If there are multiple files in the project almost all of them will produce errors for the things they are importing from node modules. But only sometimes 😕

error TS6059: File '.../node_modules/find-cache-dir/index.js' is not under 'rootDir' '.../src'. 'rootDir' is expected to contain all source files.
@mhegazy mhegazy added the Bug A bug in TypeScript label Oct 19, 2017
@mhegazy mhegazy added this to the TypeScript 2.6.1 milestone Oct 19, 2017
@Jessidhia
Copy link
Author

This actually looks like a duplicate/side-effect of #19290

@mhegazy
Copy link
Contributor

mhegazy commented Oct 19, 2017

@Kovensky can u share your project?

@sheetalkamat
Copy link
Member

@kovensky apart from the project, can you please let us know if node_modules folder is at root folder like c:/ or /user/username. That might help us investigate this further.
did you notice any pattern in edits that cause the errors to go away..
Doing tsc -w —extendedDiangostics would also give more info on what watches are being triggered to help us investigate it better

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Oct 19, 2017
@Jessidhia
Copy link
Author

The change can be as simple as adding a newline to the end of the file. I can't seem to get it to not happen anymore.

In this example, I started a build with -w --extendedDiagnostics, and after the initial build at 14:15:28 finished I added an extra empty line to webpack.config.ts:

14:15:28 - Compilation complete. Watching for file changes.


DirectoryWatcher recursive:: Added: PathInfo: /users/kovensky/src/work/webpack/src
FileWatcher:: Trigger: /Users/kovensky/src/work/webpack/src/webpack.config.ts 1 PathInfo: /Users/kovensky/src/work/webpack/src/webpack.config.ts
FileWatcher:: Elapsed: 1ms Trigger: /Users/kovensky/src/work/webpack/src/webpack.config.ts 1 PathInfo: /Users/kovensky/src/work/webpack/src/webpack.config.ts
14:15:30 - File change detected. Starting incremental compilation...


Synchronizing program
error TS6059: File '/Users/kovensky/src/work/node_modules/babel-plugin-transform-class-properties/lib/index.js' is not under 'rootDir' '/Users/kovensky/src/work/webpack/src'. 'rootDir' is expected to contain all source files.

(followed by 20 or so similar errors with different node modules)

The output directory structure is also strange. With --outDir dist, the initial compilation is as expected (e.g. dist/webpack.config.js), but the buggy incremental build puts the output in dist/webpack/src, and only the incrementally built files are in there.

sheetalkamat added a commit that referenced this issue Oct 24, 2017
@sheetalkamat
Copy link
Member

@Kovensky Thank you for the information.. I did some experimentation based on error you are getting and directory structure you mentioned and i have found a repro for this (ab67477). I am working on the fix

sheetalkamat added a commit that referenced this issue Oct 24, 2017
… existing program structure

This marks files reused correctly as from external library resulting in not using them for files to be emitted and computed for output structure
Fixes #19327
@mhegazy mhegazy added Fixed A PR has been merged for this issue and removed Needs More Info The issue still hasn't been fully clarified labels Oct 24, 2017
sheetalkamat added a commit that referenced this issue Oct 24, 2017
sheetalkamat added a commit that referenced this issue Oct 24, 2017
… existing program structure

This marks files reused correctly as from external library resulting in not using them for files to be emitted and computed for output structure
Fixes #19327
@mhegazy
Copy link
Contributor

mhegazy commented Oct 24, 2017

@Kovensky can you give tomorrow's typescript@next another try.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
3 participants