Reputation: 11260
I have been following the tutorials to try to get Typescript working with Angular 2. The problem is that I cannot seem to compile subdirectories and preserve the subdirectories.
My tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"outDir": "build",
"sourceMap": true,
"sourceRoot": "src",
"experimentalDecorators": true,
"noEmitOnError": true,
"noImplicitAny": true,
"removeComments": false
},
"exclude": [
"build",
"client",
"GulpTasks",
"node_modules",
"typings"
]
}
Now my source code has different modules and client/server folders for the project.
+build
+node_modules
+src
---+client
---+dir1
---+file1.ts
---+dir2
---+server
---+file1.ts
+typings
I need to preserve the directory structure when compiling, but files found in the subdirectory (src/server) do not preserve the server subdirectory folder when moved into the build folder. There is not a build/server/file1.js, but it is just build/file1.js.
How can you configure tsc to move files with the subdirectory when writing the JS files? I have some files in the src/client/dir1 that have the same name as the server/dir1 files and cannot have one overwrite the other.
Upvotes: 6
Views: 5465
Reputation: 22382
It looks like you should set 'rootDir' to get desired effect and use at least typescript 1.7.
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"outDir": "build",
"sourceMap": true,
"rootDir": "src",
"experimentalDecorators": true,
"noEmitOnError": true,
"noImplicitAny": true,
"removeComments": false
},
"exclude": [
"build",
"client",
"GulpTasks",
"node_modules",
"typings"
]
}
See the following issue at github: link
Upvotes: 9