You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I reached out to ts-jest through their Slack Channel, and one of the main contributors / owner @huafu responded almost immediately. I originally reached out to attempt to understand their lookup logic for the ts/babel config files. I mentioned our interests in normalizing the behavior
@huafu suggested a different overall approach, which I agree will be in the best interest of the long-term growth of vue-jest. Instead of trying to parallel the behavior, piggy-back off the existing babel-jest and ts-jest libraries to create the transformers.
It would obviously be a larger change (probably more of a partial rewrite), but the interface to consumers could potentially be the same given the other changes we are making (i.e. #111).
I was going to take a screenshot of the conversation and attach it, but for the sake of indexing I will copy over the good bits. The formatting may not be perfect:
[--START QUOTE--] huafu [9:27 PM]
You should not bother to find tsconfig, neither you should bother to find babel config. Instead (short dirty version for explanation):
If you really need to find the tsconfig and babel config, I’d suggest you use ts-jest for this to not re-invent the wheel, especially since jest is not calling any initialize method of transformers.
All the config is loaded, parsed, normalized and cached automatically in the config-set. You can access it like that:
import{createTransformer}from'ts-jest'consttr=createTransformer();// will be your own transformer instanceconstcs=tr.configsFor(jestConfig/* stringified as coming from getCacheKey() or the object as coming from process() */)// the cs is a config set which will resolve all your config (babel or ts) and get you a ts compiler with memory cache and disc cache, as well as the babel transformer
cs.jest// jest config as object, resolved, normalized and cachedcs.tsJest// same for ts-jest optonscs.babel// same for babel configcs.typescript// same for tsconfig <== this is actually what you asked forcs.tsCompiler// the configured typescript compiler (as defined by ts-jest there https://github.com/kulshekhar/ts-jest/blob/645558b289076dd8d4bd22aedafa32bd1ab1a751/src/types.ts#L169-L176)cs.babelJestTransformer// the configured babel transformer (ie you can call process() on it then as jest would do on a transformer
I reached out to ts-jest through their Slack Channel, and one of the main contributors / owner @huafu responded almost immediately. I originally reached out to attempt to understand their lookup logic for the ts/babel config files. I mentioned our interests in normalizing the behavior
@huafu suggested a different overall approach, which I agree will be in the best interest of the long-term growth of
vue-jest
. Instead of trying to parallel the behavior, piggy-back off the existingbabel-jest
andts-jest
libraries to create the transformers.It would obviously be a larger change (probably more of a partial rewrite), but the interface to consumers could potentially be the same given the other changes we are making (i.e. #111).
I was going to take a screenshot of the conversation and attach it, but for the sake of indexing I will copy over the good bits. The formatting may not be perfect:
[--START QUOTE--]
huafu [9:27 PM]
You should not bother to find tsconfig, neither you should bother to find babel config. Instead (short dirty version for explanation):
to compile js:
to compile ts:
If you really need to find the tsconfig and babel config, I’d suggest you use
ts-jest
for this to not re-invent the wheel, especially since jest is not calling anyinitialize
method of transformers.All the config is loaded, parsed, normalized and cached automatically in the config-set. You can access it like that:
You have also other utils there that might be useful as
cs.resolvePath
,you also might be interested in https://kulshekhar.github.io/ts-jest/tech/process/
[--/ENDQUOTE--]
huge shoutout to @huafu for the direction.
The text was updated successfully, but these errors were encountered: