Search Terms:
tsc -w watch exclude subfolder recompile
tsconfig.json
{
"compilerOptions": {
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es7"], /* Specify library files to be included in the compilation. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"outDir": "dist", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"watch": true,
},
"exclude": [
"node_modules",
"dist",
"upload",
]
}
Folder structure
Expected behavior:
When i create a file into upload/
, tsc should not detect file changes.
Actual behavior:
When i create a file into upload/
, server detects file changes and do incremental compilation.
i'm using "tsc-watch --onSuccess \"node dist/server.js\""
, so, my server is restarted whenever user upload a file.
Is there any way to tsc -w not detect file creation in an excluded project's subfolder?
Thanks in advance.
This is by design. Normally even though file is excluded by the config file, it could get included by module resolution and could be missing. So we cant just ignore file addition or removal of file in exclude directory.
Any proposals on how to solve the problem, if this is by design so? It's still a problem, makes file upload testing impossible with watch
Would very much appreciate some solution to this as well.
This is by design. Normally even though file is excluded by the config file, it could get included by module resolution and could be missing. So we cant just ignore file addition or removal of file in exclude directory.
@sheetalkamat the excluded file should be part of the build, yes - but it should not trigger a rebuild on change if it is excluded.
I've been dealing with this issue on two separate projects. Nest uses tsc --watch
internally for their build triggering, and I'd love to have a folder NOT trigger a rebuild of a project. Super irritating.
also experiencing this issue, also with nest - we are using sqlite and _any database update_ is triggering a rebuild and thus a server restart.
Same issue here. Anyone is able to solve this?
same here
Same issue here. With Nest.js.
also experiencing this issue, also with nest - we are using sqlite and _any database update_ is triggering a rebuild and thus a server restart.
Exactly the same issue with LevelDB and NestJS
I have the same problem with Nest JS, and no solution for this is making the development for certain cases like simple file upload a real pain.
There is a solution in this comment
Same issue here. With Nest.js.
https://github.com/Microsoft/TypeScript/issues/27279#issuecomment-625998815
Solved it.
And put your upload directory inside of dir for example.
The approach in #27279 does not resolve this issue for me.
I'm running tsc -w and webpack side-by-side, with tsc purely checking for ts errors and webpack producing a js bundle.
Every time webpack places a new hot-update.js or hot-update.json file in the build folder, that triggers tsc to recompile. I've confirmed this with the --exendedDiagnostics
flag:
DirectoryWatcher:: Triggered with /Users/{redacted}/GitHub/{redacted}/packages/{redacted}/build/main.852665aec4d5e06ecc09.hot-update.js
My tsconfig:
{
...
"include": ["packages/*/src/**/*"]
}
Please give us a way to control which files can or cannot trigger a recompile!
this seems poorly designed. I do not think the stated reason is sufficient. shift the burdon/power to the developers by allowing this exclusion in watch mode.
I'm hopeful that https://github.com/microsoft/TypeScript/pull/39030 will fix this (merged, but not released yet).
If anyone is still facing the same issue, I solved this by adding the include
option in my tsconfig.json to only watch those directories without the static files. An example:
"include": [
"src"
]
At the moment, the exclude
option does not work.
It doesn't work for me
tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"resolveJsonModule": true,
"strictNullChecks": false,
},
"exclude": ["node_modules", "dist", "data", "uploads"],
"include": ["src"]
}
data
is docker mount volumes and uploads
is file upload folder
Most helpful comment
Same issue here. With Nest.js.