grunt-ts
grunt-ts copied to clipboard
Stop creating .baseDir.ts file
Creating the .baseDir.ts file now causes issues if the isolatedModules option is specified, and my understanding of it is that, with the rootDir option in Typescript, it should no longer be necessary.
I can submit a PR for this, I just wanted to double-check that my assumptions are correct before doing so.
This is definitely something I have been meaning to look into. We do still need to support legacy TypeScript versions, but perhaps if rootDir is specified, we can skip the emit.
Before coding anything, can you explain what you intend to do and how the new functionality still addresses the original use-case?
Thanks for contributing!
Ah, I had not considered backwards compatibility, that's fair.
In that case, I think all that would be required would be to include !options.rootDir in the if statement to check for whether the .baseDir.ts file should be created. That way, for people using a compiler older than the baseDir option, nothing will change. For anyone using a newer compiler, and manually specifying baseDir, that file will not exist and it will be perfectly fine to use isolatedModules.
I've never fully understood this feature and there's no tests written around it, so I'll have to think about this a bit. If you feel confident that this solution will work, please go ahead and implement the change and send a PR.
Please include two integration tests. One that should emit a .baseDir.ts file and one that should not emit one. The tests are in the Gruntfile.js - a good example that you can copy is outDir_with_spaces.
Then, add an assertion to test/test.ts for your new targets. By convention, we use the test/expected folder to compare against any compilation artifacts created in test.
Submit the PR for that and we'll go from there. Feel free to ask any questions you may have. We need to document this all better. Thanks!
Creating the .baseDir.ts file now causes issues if the isolatedModules option is specified, and my understanding of it is that, with the rootDir option in Typescript, it should no longer be necessary.
Indeed .baseDir.ts was a hack around the lack of official support for something like rootDir or tsconfig.json. The original discussion which resulted in this feature : https://github.com/TypeStrong/grunt-ts/issues/77
To be honest I feel that once we had tsconfig.json there wasn't a need for another option (e.g. rootDir) and I did resist it ... but not enough : https://github.com/Microsoft/TypeScript/pull/2034#issuecomment-94649963 as I might be wrong ¯\_(ツ)_/¯ I still recommend thinking of tsconfig.json as your rootDir and not using this option explicitly.
I have tried to set a bunch of different options to try and get rid of the .baseDir.ts file. The fact that it is generated in the source and not the target directory means all of our developers have to specifically ignore it. I am setting rootDir, so hoping we can get this removed. If there is a way to do it now, that would be great. It looks like this issue is still open?
Hi - yes it's still open. It's mainly a lack of time to dig into it rather than intent. PRs definitely accepted that provide reasonable functionality for old TS (perhaps, but not necessarily using the existing feature) and new TS with native rootDir support.
After looking into this further, I think that the baseDir feature is not doing much for us anymore with the implementation of rootDir. I am going to work on getting the .baseDir functionality removed as long as rootDir is specified (will not worry about backwards compat by revving major version)
Is there any way with current versions to not generate the .basedir.ts ?
Did this ever get fixed? I am researching all the various threads about this, but even with the latest beta, I still get a .baseDir.ts file in my source directory. Is there an option or something I can do to suppress that with grunt-ts?
Hi, It's not fixed. I recommend adding .baseDir.ts to your .gitignore file (or similar) and ignore it if at all possible. It's just a matter of digging in to this and I haven't had the energy, to be honest. Pull requests gladly accepted. :-)
This should be fixed now thanks to @nobuoka and an additional tweak I've implemented. Please try on grunt-ts 6.0.0-beta.16. You will have to also specify rootDir in your options object when you specify outDir.