Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have a way to skip typescript's module transform #767

Closed
Jessidhia opened this issue Sep 27, 2018 · 1 comment · May be fixed by procrafts/kata-diamond#20, procrafts/kata-diamond#21 or procrafts/kata-diamond#22
Labels
Milestone

Comments

@Jessidhia
Copy link

Jessidhia commented Sep 27, 2018

Issue :

ts-jest currently forces the value of the tsconfig option module to be commonjs here; however, this breaks use cases where both typescript and babel are used to transform code when the babel transform expects its input to still be in module form.

There seems to be code that appears intended to support this use case, but it's broken by the loop at the end of readTsConfig which forcibly overrides everything.

This issue affects at least babel-plugin-emotion: emotion-js/emotion#687

Disabling it would, of course, require that the user runs babel's transform instead, but the only use case for disabling it is when you have to also run babel anyway.

Expected behavior :

ts-jest to either respect the module setting in tsconfig, or to have a way to opt out of ts-jest's overriding of the module option.

Debug log:

log file content
# content of ts-jest.log :
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsconfig":{"input":{"compilerOptions":{"types":["node","facebook-js-sdk","google.analytics"]},"extends":"../src/tsconfig.json","files":["../src/webpack.d.ts","../src/declarations.d.ts"]},"resolved":{"compileOnSave":false,"configFileSpecs":{"excludeSpecs":[...],"filesSpecs":[...],"validatedExcludeSpecs":[...],"wildcardDirectories":{}},"errors":[],"fileNames":[...],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"baseUrl":".../src","configFilePath":".../jest/jest.tsconfig.json","declaration":false,"esModuleInterop":true,"importHelpers":true,"inlineSourceMap":false,"inlineSources":true,"isolatedModules":true,"jsx":1,"lib":["lib.es2015.d.ts","lib.es2016.d.ts","lib.es2017.d.ts","lib.esnext.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts"],"maxNodeModuleJsDepth":0,"module":1,"moduleResolution":2,"noEmit":false,"noEmitHelpers":true,"noImplicitAny":true,"noImplicitThis":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"$$ts-jest$$","plugins":[{"name":"typescript-styled-plugin"}],"removeComments":false,"skipLibCheck":true,"sourceMap":true,"strict":true,"strictNullChecks":true,"target":6,"types":["node","facebook-js-sdk","google.analytics"]},"raw":{"compileOnSave":false,"compilerOptions":{"types":["node","facebook-js-sdk","google.analytics"]},"exclude":[...],"extends":"../src/tsconfig.json","files":[...]},"typeAcquisition":{"enable":false,"exclude":[],"include":[]},"wildcardDirectories":{}}},"version":"23.10.2"},"message":"normalized typescript config","sequence":19,"time":"2018-09-27T05:01:11.287Z"}

(note the "module":1; it should be "module":6 if esnext was being respected)

Minimal repo :

This comment in an affected plugin's issues links to a reproduction repo: emotion-js/emotion#687 (comment)

@huafu huafu added this to the 23.10.3 milestone Sep 27, 2018
@huafu huafu added the 🐛 Bug label Sep 27, 2018
@huafu
Copy link
Collaborator

huafu commented Sep 27, 2018

@Kovensky thanks a lot for this issue. I think the easier would be to NOT override module at all as soon as babel option is defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment