Repository navigation
Feature Request: Add support for "Solution Style" tsconfig.json file #1057
Description
Activity
yeah this is SORELY missed - moving to using references basically made all development scripts break now :-\
In the short-term I recommend turning on transpileOnly mode. You can configure this flag directly in your solution-style tsconfig file.
Can't if you use compile transformers.
You might be able to get something working by nesting other options -- not transpileOnly -- within the "ts-node" sub-object of your root tsconfig file. I'm not sure without seeing how your project is set up, but it might work.
Can you share more details about your use-case? Which compile transformers are you using, and how do they relate to your development scripts? Is it possible or impossible to write an alternative tsconfig file that ts-node reads?
Either way, the best chance of getting this implemented is if someone sends us a pull request. Without going into detail, the current state of the world is affecting my free time.
Yeah I kind of use my
tsconfig.base.jsonin some cases, i will play around with that. While not ideal it may do the job.I am using the transform-paths plugin in order to rewrite imports according to
pathsandbaseUrl"plugins": [ { "transform": "@zerollup/ts-transform-paths" } ]Keep in mind you can specify alternative compiler options nested inside your tsconfig's "ts-node" object. So you can let
ts-nodeuse the default tsconfig file, but hand it a custom set of compilerOptions.A few more questions:
Does that plugin require typechecking, or is it compatible with transpileOnly mode? It's rewriting import paths, right? Are you usingttypescript? Have you looked at using https://www.npmjs.com/package/tsconfig-paths for your development scripts, and if so, what are the blockers with that approach?@cspotcode first of all thanks a ton for your help here and taking the time - much appreciated!
I believe
tsconfig-pathsis required at runtime, no? The benefit ofts-transform-pathswas that it simply rewrites the paths of the imports so nothing is required at runtime to support the absolute-style paths. I could be incorrect, it has been awhile?However, potentially could use that for dev and use the transformer for production - which may be why you said
for your development scripts:-PI do not think the transformer works with
transpileOnly- there is an issue zerkalica/zerollup#31Keep in mind you can specify alternative compiler options nested inside your tsconfig's "ts-node" object. So you can let ts-node use the default tsconfig file, but hand it a custom set of compilerOptions.
I will have to play around with that as well
@bradennapier You're correct:
tsconfig-pathsis required at runtime. And yes, I was suggesting it as a fix for your development scripts. Though I understand that using 2 different tools is adding complexity.Thanks for linking that ticket. ttypescript supports an alternative interface where it passes
CompilerOptionsto the transformer factory instead ofProgram. I wonder, can the transformer be updated to use that interface? But theCompilerOptionsmight suffer from the same problem, missingpaths.
https://github.com/cevek/ttypescript/tree/master/packages/ttypescript#compileroptionsIt wouldn't even be that terrible to need to define paths as a config option or something if it would make things work nicely :-P but yeah, that is past my understanding of the ts compiler. https://github.com/bradennapier/eslint-plugin-ts-import is about the extent of my compiler experience and I ended up just using
tsconfig-pathsin the end to make it easy on me :-)@cspotcode well looksl ike i pretty quickly ran into jonaskello/tsconfig-paths#133 with that attempt :-P -- we use
esModuleInteropand due to that when I am using this it seems to fail to resolve anything that requires it :-\ - it is different issue here but i thnk it may be due to similar issue? Maybe not though :-P
After spending the last 2 hours on that .. I guess the compilerOptions do not work with
extends- so when I am usingextendsin the tsconfig with--script-modeit ends up not finding any of the compilerOptions soesModuleInteropis not true. Seems I would have to copy thecompilerOptionsto all 35 referenced projects?@bradennapier are you referring to how
tsconfig-pathsreadscompilerOptions, or howts-nodereadscompilerOptions?Copying a config flag to 35 referenced projects is honestly not that hard, pragmatically speaking. If that's all it takes to get you unblocked, you should go for it.
using
--script-modefixed my issue when combined with--transpile-only. Althoughts-node-devdoesn't support it so I am submitting a PR (and their--diris configured as a boolean so that doesnt work either).Think I am finally close :-) thanks again.
wclr/ts-node-dev#183 -- with that PR i am fully unblocked and working with
transpileOnlyin dev mode <3
In case anyone runs into this and needs help with it - I needed to do the following:
// ./register.js const path = require('path'); const { loadConfig, register } = require('tsconfig-paths'); const dirName = path.dirname(process.argv[process.argv.length - 1]); const config = loadConfig(dirName); // dev support for absolute path resolution while allowing transpileOnly to work register({ baseUrl: config.absoluteBaseUrl, paths: config.paths });
then in my
package.jsonscript I can do something like:ts-node-dev -s -H -T -r ./register --respawn -- src/services/rest-api/index.tsNote for the
-soption to work the PR I linked above is going to need to be merged. Since it doesn't take any building you can prob just install that directly from git though:yarn add --dev git://github.com/bradennapier/ts-node-dev.git#feature/script-mode"Reacted by lamkovod
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#support-for-solution-style-tsconfigjson-files
yarn ts-node scripts/foo.tsshould auto use./scripts/tsconfig.scripts.json