ts-jest 27.0.0-next.8 → 27.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ts-jest-digest +1 -1
- package/CHANGELOG.md +215 -9
- package/README.md +4 -5
- package/dist/cli/config/migrate.js +22 -19
- package/dist/compiler/compiler-utils.d.ts +1 -1
- package/dist/compiler/compiler-utils.js +9 -3
- package/dist/compiler/ts-compiler.d.ts +3 -3
- package/dist/compiler/ts-compiler.js +131 -90
- package/dist/compiler/ts-jest-compiler.d.ts +8 -1
- package/dist/compiler/ts-jest-compiler.js +2 -2
- package/dist/config/config-set.js +12 -12
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -5
- package/dist/raw-compiler-options.d.ts +6 -5
- package/dist/ts-jest-transformer.d.ts +5 -5
- package/dist/ts-jest-transformer.js +12 -1
- package/dist/types.d.ts +7 -1
- package/dist/utils/json.js +5 -2
- package/dist/utils/version-checkers.js +2 -2
- package/package.json +23 -15
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
379ec6d53df43eff4f1a882c7005e069f36949a1
|
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,231 @@
|
|
|
1
|
-
|
|
1
|
+
## [27.0.2](https://github.com/kulshekhar/ts-jest/compare/v27.0.1...v27.0.2) (2021-05-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **compiler:** add empty string file content to compiler cache ([#2633](https://github.com/kulshekhar/ts-jest/issues/2633)) ([0feb556](https://github.com/kulshekhar/ts-jest/commit/0feb5560a588f87d1d989bf521859fba0fda20fe)), closes [#2625](https://github.com/kulshekhar/ts-jest/issues/2625)
|
|
7
|
+
* **config:** `exclude` should only exclude files which match glob values ([#2637](https://github.com/kulshekhar/ts-jest/issues/2637)) ([c5ce979](https://github.com/kulshekhar/ts-jest/commit/c5ce97902c1b84dc354f270a4f596a6f5f634611)), closes [#2634](https://github.com/kulshekhar/ts-jest/issues/2634)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [27.0.1](https://github.com/kulshekhar/ts-jest/compare/v27.0.0...v27.0.1) (2021-05-26)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **cli:** keep `testMatch` if old jest config contains it ([#2618](https://github.com/kulshekhar/ts-jest/issues/2618)) ([c568f49](https://github.com/kulshekhar/ts-jest/commit/c568f49907fb5559ba1e8c67f1ec5d5eb4af920a)), closes [#2616](https://github.com/kulshekhar/ts-jest/issues/2616)
|
|
17
|
+
* **compiler:** make sure `isolatedModules: false` use updated compiler options ([#2628](https://github.com/kulshekhar/ts-jest/issues/2628)) ([348e30f](https://github.com/kulshekhar/ts-jest/commit/348e30f426803efc51ecba26ab42619938fcb5af)), closes [#2629](https://github.com/kulshekhar/ts-jest/issues/2629)
|
|
18
|
+
* add missing export `presets` ([#2624](https://github.com/kulshekhar/ts-jest/issues/2624)) ([0ea025e](https://github.com/kulshekhar/ts-jest/commit/0ea025ebb456d3a31671e31fac0b401c2734a2b1)), closes [#2623](https://github.com/kulshekhar/ts-jest/issues/2623)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [27.0.0](https://github.com/kulshekhar/ts-jest/compare/v26.5.6...v27.0.0) (2021-05-25)
|
|
2
23
|
|
|
3
24
|
|
|
4
25
|
### Bug Fixes
|
|
5
26
|
|
|
27
|
+
* **compiler:** return file content on emitSkipped for non ts/tsx files ([#2519](https://github.com/kulshekhar/ts-jest/issues/2519)) ([a4e5640](https://github.com/kulshekhar/ts-jest/commit/a4e5640f54a7810c9b7aba32663ce4a53893d22f)), closes [#2513](https://github.com/kulshekhar/ts-jest/issues/2513)
|
|
28
|
+
* **compiler:** retype check other files if processing file is used by those ones in watch mode ([#2481](https://github.com/kulshekhar/ts-jest/issues/2481)) ([ac8f3d0](https://github.com/kulshekhar/ts-jest/commit/ac8f3d025de67bfc2708a8422ee657fc42455513)), closes [#943](https://github.com/kulshekhar/ts-jest/issues/943)
|
|
29
|
+
* **compiler:** initialize compiler with `.ts`/`.tsx`/`.d.ts` files only ([#2458](https://github.com/kulshekhar/ts-jest/issues/2458)) ([a89f0e2](https://github.com/kulshekhar/ts-jest/commit/a89f0e2061e01440337dde4134639ff6a2d69936)), closes [#2445](https://github.com/kulshekhar/ts-jest/issues/2445)
|
|
6
30
|
* **compiler:** resolve nested imported modules for each processing file ([#2436](https://github.com/kulshekhar/ts-jest/issues/2436)) ([3cb9019](https://github.com/kulshekhar/ts-jest/commit/3cb9019289bb64deecffaf52e840faf6a4656092)), closes [#1390](https://github.com/kulshekhar/ts-jest/issues/1390) [#1747](https://github.com/kulshekhar/ts-jest/issues/1747)
|
|
7
31
|
* **config:** create fallback jest config when jest config is `undefined` ([#2433](https://github.com/kulshekhar/ts-jest/issues/2433)) ([c6d6e4c](https://github.com/kulshekhar/ts-jest/commit/c6d6e4cd534e1c368fcb7141784ee43584525ca4)), closes [#2085](https://github.com/kulshekhar/ts-jest/issues/2085)
|
|
8
32
|
* remove `@types/jest` from direct dep ([#2409](https://github.com/kulshekhar/ts-jest/issues/2409)) ([8913120](https://github.com/kulshekhar/ts-jest/commit/89131203c358c8f9e89655800e500a9e88a17334)), closes [#2406](https://github.com/kulshekhar/ts-jest/issues/2406) [#2411](https://github.com/kulshekhar/ts-jest/issues/2411)
|
|
9
33
|
* **compiler:** return original file content and show warning on emit skip ([#2410](https://github.com/kulshekhar/ts-jest/issues/2410)) ([c2b2164](https://github.com/kulshekhar/ts-jest/commit/c2b2164ddd1e606fc2490326244a6efc63f6c4a0)), closes [#2407](https://github.com/kulshekhar/ts-jest/issues/2407)
|
|
10
34
|
* **compiler:** type check correctly in watch mode when a file content itself has changed ([#2405](https://github.com/kulshekhar/ts-jest/issues/2405)) ([064bf3a](https://github.com/kulshekhar/ts-jest/commit/064bf3a73e9a304aa9366d27db8973b68be23ffd)), closes [#2118](https://github.com/kulshekhar/ts-jest/issues/2118)
|
|
35
|
+
* **compiler:** exclude files in `outDir` from compiler source files ([#2375](https://github.com/kulshekhar/ts-jest/issues/2375)) ([ec68c74](https://github.com/kulshekhar/ts-jest/commit/ec68c74bccf56d682a7ed9e5c48ea676dcf3fbf9)), closes [#2350](https://github.com/kulshekhar/ts-jest/issues/2350) [#2374](https://github.com/kulshekhar/ts-jest/issues/2374)
|
|
36
|
+
* **config:** cache config and compiler correctly between runs ([#2356](https://github.com/kulshekhar/ts-jest/issues/2356)) ([5f91336](https://github.com/kulshekhar/ts-jest/commit/5f91336b9023da1051cc85b509ad02c525679fcb))
|
|
37
|
+
* **config:** improve emit skipped error message ([#2358](https://github.com/kulshekhar/ts-jest/issues/2358)) ([2ae8df4](https://github.com/kulshekhar/ts-jest/commit/2ae8df4515d6f6e975e57719a89184b5583f9e2f)), closes [#2350](https://github.com/kulshekhar/ts-jest/issues/2350)
|
|
38
|
+
* **typings:** set correct typing for `tsconfig` option ([#2383](https://github.com/kulshekhar/ts-jest/issues/2383)) ([584324a](https://github.com/kulshekhar/ts-jest/commit/584324a60c0784275e9bf8bcfd0814735a250d24)), closes [#2368](https://github.com/kulshekhar/ts-jest/issues/2368)
|
|
39
|
+
* **config:** invalidate Jest transform cache when `astTransformers` value changes ([#2345](https://github.com/kulshekhar/ts-jest/issues/2345)) ([d726016](https://github.com/kulshekhar/ts-jest/commit/d726016a17a26215fad782cf57bb9b9bec807307))
|
|
40
|
+
* reduce size of `node_modules` when adding `ts-jest` ([#2263](https://github.com/kulshekhar/ts-jest/issues/2263)) ([8e0675c](https://github.com/kulshekhar/ts-jest/commit/8e0675c02b6095af6656df50c8782c01ad9e87a3))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* **config:** allow disable sourcemap ([#2544](https://github.com/kulshekhar/ts-jest/issues/2544)) ([47da6ad](https://github.com/kulshekhar/ts-jest/commit/47da6ada5089e58e9bc68ce8e9bc9e17aaa127ae))
|
|
46
|
+
* **compiler:** expose `TsCompiler` as public api ([#2344](https://github.com/kulshekhar/ts-jest/issues/2344)) ([871cd6a](https://github.com/kulshekhar/ts-jest/commit/871cd6a3abb10569a04d05f72bbb41c952665ed4))
|
|
47
|
+
* **config:** support typed config options for jest config typescript ([#2335](https://github.com/kulshekhar/ts-jest/issues/2335)) ([3cfc37b](https://github.com/kulshekhar/ts-jest/commit/3cfc37b1eba125fe861cea0415095dbe1f538520))
|
|
48
|
+
* **presets:** add typing for `presets` entry point ([#2337](https://github.com/kulshekhar/ts-jest/issues/2337)) ([1a3058f](https://github.com/kulshekhar/ts-jest/commit/1a3058f3b7f8a2e377cb6a7e829cea310a06d4fa))
|
|
49
|
+
* **compiler:** allow custom transformers to access internal `Program` ([#2299](https://github.com/kulshekhar/ts-jest/issues/2299)) ([387964f](https://github.com/kulshekhar/ts-jest/commit/387964faed14ce24d2cf8170a04eee244d69b8b9))
|
|
50
|
+
* **config:** replace `pathRegex` with `exclude` ([#2295](https://github.com/kulshekhar/ts-jest/issues/2295)) ([f2f99c3](https://github.com/kulshekhar/ts-jest/commit/f2f99c3a46ac18a1fd6cc98922329b71a7e8c4e8))
|
|
51
|
+
* **config:** type checking `js` files based on `checkJs` ([#2283](https://github.com/kulshekhar/ts-jest/issues/2283)) ([1e04433](https://github.com/kulshekhar/ts-jest/commit/1e044335a38907ff5c06eb43efeb2e5fd9769a0c))
|
|
52
|
+
* **compiler:** support ESM for `isolatedModules: false` ([#2269](https://github.com/kulshekhar/ts-jest/issues/2269)) ([9bb0c05](https://github.com/kulshekhar/ts-jest/commit/9bb0c054a3a7bd8949b0c12b2bb42348f69e2e2e)), closes [#1709](https://github.com/kulshekhar/ts-jest/issues/1709)
|
|
53
|
+
* **compiler:** support ESM for `isolatedModule: true` ([#2219](https://github.com/kulshekhar/ts-jest/issues/2219)) ([e101db0](https://github.com/kulshekhar/ts-jest/commit/e101db01095ce75ce9a48e27a1d9bf84bb8e19ee)), closes [#1709](https://github.com/kulshekhar/ts-jest/issues/1709)
|
|
54
|
+
* **presets:** add 3 new presets to work with ESM ([#2207](https://github.com/kulshekhar/ts-jest/issues/2207)) ([c277858](https://github.com/kulshekhar/ts-jest/commit/c277858c7820d8873c2d7d0c6e3704a47868d600))
|
|
55
|
+
* allow subclasses of `TsJestTransformer` to have version checking ([#2176](https://github.com/kulshekhar/ts-jest/issues/2176)) ([ca8d7c4](https://github.com/kulshekhar/ts-jest/commit/ca8d7c44779105ef208d17cdd8c6baaf96b479ad))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Performance Improvements
|
|
59
|
+
|
|
60
|
+
* reuse jest file system cache for `isolatedModules: false` ([#2189](https://github.com/kulshekhar/ts-jest/issues/2189)) ([68f446b](https://github.com/kulshekhar/ts-jest/commit/68f446b8351bb8925ac4822aa631aa6b23f2f711))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Code Refactoring
|
|
64
|
+
|
|
65
|
+
* **config:** remove support for `astTransformers` string array ([#2129](https://github.com/kulshekhar/ts-jest/issues/2129)) ([1e0b2ce](https://github.com/kulshekhar/ts-jest/commit/1e0b2ce5599a35c108712456e455bf29c8c5fd24))
|
|
66
|
+
* **config:** remove support for `packageJson` option ([#2128](https://github.com/kulshekhar/ts-jest/issues/2128)) ([05916b9](https://github.com/kulshekhar/ts-jest/commit/05916b920160da5b43a20b47025eea43b4a1a5c3))
|
|
67
|
+
* move jest transformer class to package entry ([#2122](https://github.com/kulshekhar/ts-jest/issues/2122)) ([5bbfd06](https://github.com/kulshekhar/ts-jest/commit/5bbfd06a0c114dbecd75b763bcfa76d4a6203ab1))
|
|
68
|
+
* **config:** remove support for `tsConfig` option ([#2127](https://github.com/kulshekhar/ts-jest/issues/2127)) ([3cc9b80](https://github.com/kulshekhar/ts-jest/commit/3cc9b806be2b2096b981253d39ca40df65bb0f7b))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## BREAKING CHANGES
|
|
72
|
+
|
|
73
|
+
* By default, `ts-jest` will use `sourceMap` option from your `tsconfig`. If users want to have sourcemap on, they need to set `sourceMap: true` in `tsconfig`.
|
|
74
|
+
* follow Jest support Node engines ([#2478](https://github.com/kulshekhar/ts-jest/pull/2478)) ([1fecf7f](https://github.com/kulshekhar/ts-jest/commit/1fecf7ff92a5f1a0cc6ea1d27026f9f54a3d5ead))
|
|
75
|
+
* add `exports` field to `package.json`, see https://nodejs.org/api/packages.html#packages_package_entry_points ([#2467](https://github.com/kulshekhar/ts-jest/pull/2467)) ([d3aba3e](https://github.com/kulshekhar/ts-jest/commit/d3aba3e103f85b3a42d0e2ecaea9d3457917319e))
|
|
76
|
+
* `ts-jest` custom AST transformer function signature has changed to
|
|
77
|
+
```
|
|
78
|
+
import type { TsCompilerInstance } from 'ts-jest/dist/types'
|
|
79
|
+
|
|
80
|
+
export function factory(compilerInstance: TsCompilerInstance) {
|
|
81
|
+
//...
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
* One is currently using `pathRegex` should use `exclude` with `glob` patterns.
|
|
85
|
+
* If one currently relies on type check for `js` files, please set `checkJs: true` in your tsconfig.
|
|
86
|
+
* Now both `isolatedModules: true` and `isolatedModule: false` codes are in one single class `TsCompiler` which is an instance created in `TsJestCompiler` based on config option `compiler` with value `typescript` or `ttypescript`.
|
|
87
|
+
* **config:** `packageJson` config option is not used in internal `ts-jest` so this option is now removed.
|
|
88
|
+
* **config:** One is defining ast transformers in `jest.config.js`/`package.json` should change to
|
|
89
|
+
```
|
|
90
|
+
// jest.config.js
|
|
91
|
+
module.exports = {
|
|
92
|
+
//...
|
|
93
|
+
globals: {
|
|
94
|
+
'ts-jest': {
|
|
95
|
+
astTransformers: {
|
|
96
|
+
before: ['your_before_transformer_path'],
|
|
97
|
+
after: ['your_after_transformer_path'],
|
|
98
|
+
afterDeclarations: ['your_afterDeclarations_transformer_path'],
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
or
|
|
106
|
+
```
|
|
107
|
+
// package.json
|
|
108
|
+
{
|
|
109
|
+
"jest": {
|
|
110
|
+
"globals": {
|
|
111
|
+
"ts-jest": {
|
|
112
|
+
"astTransformers": {
|
|
113
|
+
"before": ["your_before_transformer_path"],
|
|
114
|
+
"after": ["your_after_transformer_path"],
|
|
115
|
+
"afterDeclarations": ["your_afterDeclarations_transformer_path"]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
* One currently refers type in `jest.config.js`
|
|
123
|
+
```
|
|
124
|
+
/** @typedef {import('ts-jest')} */
|
|
125
|
+
module.exports = {
|
|
126
|
+
//...
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
should change to
|
|
131
|
+
```
|
|
132
|
+
/** @typedef {import('ts-jest/dist/types')} */
|
|
133
|
+
module.exports = {
|
|
134
|
+
//...
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
* Remove possibilities to import `mocked`, `createJestPreset`, `pathsToModuleNameMapper` from package entry. One should change to
|
|
138
|
+
```
|
|
139
|
+
import { mocked, createJestPreset, pathsToModuleNameMapper } from 'ts-jest/utils'
|
|
140
|
+
```
|
|
141
|
+
* **config:** One currently uses `tsConfig` should change to `tsconfig` in your `jest.config.js` or `package.json`.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## [26.5.6](https://github.com/kulshekhar/ts-jest/compare/v26.5.5...v26.5.6) (2021-05-05)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
### Code Refactoring
|
|
149
|
+
|
|
150
|
+
* refactor(config): show warning message for `sourceMap: false` ([#2557](https://github.com/kulshekhar/ts-jest/pull/2557)) ([cf60990](https://github.com/kulshekhar/ts-jest/commit/cf609900e2c5937755123bd08ca2c5f2ff5e0651)).
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# [27.0.0-next.12](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.11...v27.0.0-next.12) (2021-05-05)
|
|
11
155
|
|
|
12
156
|
|
|
13
157
|
### Features
|
|
14
158
|
|
|
15
|
-
*
|
|
159
|
+
* **config:** allow disable sourcemap ([#2544](https://github.com/kulshekhar/ts-jest/issues/2544)) ([47da6ad](https://github.com/kulshekhar/ts-jest/commit/47da6ada5089e58e9bc68ce8e9bc9e17aaa127ae))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
## BREAKING CHANGES
|
|
163
|
+
|
|
164
|
+
* By default, `ts-jest` will use `sourceMap` option from your `tsconfig`. If users want to have sourcemap on, they need to either remove `sourceMap` or set `sourceMap: true` in `tsconfig`
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
## [26.5.5](https://github.com/kulshekhar/ts-jest/compare/v26.5.4...v26.5.5) (2021-04-15)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
### Bug Fixes
|
|
172
|
+
|
|
173
|
+
* **compiler:** return file content on emitSkipped for non ts/tsx files ([#2515](https://github.com/kulshekhar/ts-jest/issues/2515)) ([0320fb3](https://github.com/kulshekhar/ts-jest/commit/0320fb3ac22056aafe4d7ae966eab84dbf23fda9)), closes [#2513](https://github.com/kulshekhar/ts-jest/issues/2513)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
# [27.0.0-next.11](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.10...v27.0.0-next.11) (2021-04-15)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
### Bug Fixes
|
|
181
|
+
|
|
182
|
+
* **compiler:** return file content on emitSkipped for non ts/tsx files ([#2519](https://github.com/kulshekhar/ts-jest/issues/2519)) ([a4e5640](https://github.com/kulshekhar/ts-jest/commit/a4e5640f54a7810c9b7aba32663ce4a53893d22f)), closes [#2513](https://github.com/kulshekhar/ts-jest/issues/2513)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# [27.0.0-next.10](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.9...v27.0.0-next.10) (2021-03-30)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
### Bug Fixes
|
|
190
|
+
|
|
191
|
+
* **compiler:** retype check other files if processing file is used by those ones in watch mode ([#2481](https://github.com/kulshekhar/ts-jest/issues/2481)) ([ac8f3d0](https://github.com/kulshekhar/ts-jest/commit/ac8f3d025de67bfc2708a8422ee657fc42455513)), closes [#943](https://github.com/kulshekhar/ts-jest/issues/943)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
## BREAKING CHANGES
|
|
195
|
+
|
|
196
|
+
* follow Jest node engines ([#2478](https://github.com/kulshekhar/ts-jest/pull/2478)) ([1fecf7f](https://github.com/kulshekhar/ts-jest/commit/1fecf7ff92a5f1a0cc6ea1d27026f9f54a3d5ead))
|
|
197
|
+
* add `exports` field to `package.json`, see https://nodejs.org/api/packages.html#packages_package_entry_points ([#2467](https://github.com/kulshekhar/ts-jest/pull/2467)) ([d3aba3e](https://github.com/kulshekhar/ts-jest/commit/d3aba3e103f85b3a42d0e2ecaea9d3457917319e))
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
# [27.0.0-next.9](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.8...v27.0.0-next.9) (2021-03-19)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
### Bug Fixes
|
|
205
|
+
|
|
206
|
+
* **compiler:** initialize compiler with `.ts`/`.tsx`/`.d.ts` files only ([#2458](https://github.com/kulshekhar/ts-jest/issues/2458)) ([a89f0e2](https://github.com/kulshekhar/ts-jest/commit/a89f0e2061e01440337dde4134639ff6a2d69936)), closes [#2445](https://github.com/kulshekhar/ts-jest/issues/2445)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## [26.5.4](https://github.com/kulshekhar/ts-jest/compare/v26.5.3...v26.5.4) (2021-03-17)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
### Bug Fixes
|
|
214
|
+
|
|
215
|
+
* **compiler:** initialize compiler with `.ts`/`.tsx`/`.d.ts` files only ([#2457](https://github.com/kulshekhar/ts-jest/issues/2457)) ([1dc731a](https://github.com/kulshekhar/ts-jest/commit/1dc731a5faf7cda59db1cc642eb99fae973b1246)), closes [#2445](https://github.com/kulshekhar/ts-jest/issues/2445)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
# [27.0.0-next.8](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.7...v27.0.0-next.8) (2021-03-11)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
### Bug Fixes
|
|
223
|
+
|
|
224
|
+
* **compiler:** resolve nested imported modules for each processing file ([#2436](https://github.com/kulshekhar/ts-jest/issues/2436)) ([3cb9019](https://github.com/kulshekhar/ts-jest/commit/3cb9019289bb64deecffaf52e840faf6a4656092)), closes [#1390](https://github.com/kulshekhar/ts-jest/issues/1390) [#1747](https://github.com/kulshekhar/ts-jest/issues/1747)
|
|
225
|
+
* **config:** create fallback jest config when jest config is `undefined` ([#2433](https://github.com/kulshekhar/ts-jest/issues/2433)) ([c6d6e4c](https://github.com/kulshekhar/ts-jest/commit/c6d6e4cd534e1c368fcb7141784ee43584525ca4)), closes [#2085](https://github.com/kulshekhar/ts-jest/issues/2085)
|
|
226
|
+
* remove `@types/jest` from direct dep ([#2409](https://github.com/kulshekhar/ts-jest/issues/2409)) ([8913120](https://github.com/kulshekhar/ts-jest/commit/89131203c358c8f9e89655800e500a9e88a17334)), closes [#2406](https://github.com/kulshekhar/ts-jest/issues/2406) [#2411](https://github.com/kulshekhar/ts-jest/issues/2411)
|
|
227
|
+
* **compiler:** return original file content and show warning on emit skip ([#2410](https://github.com/kulshekhar/ts-jest/issues/2410)) ([c2b2164](https://github.com/kulshekhar/ts-jest/commit/c2b2164ddd1e606fc2490326244a6efc63f6c4a0)), closes [#2407](https://github.com/kulshekhar/ts-jest/issues/2407)
|
|
228
|
+
* **compiler:** type check correctly in watch mode when a file content itself has changed ([#2405](https://github.com/kulshekhar/ts-jest/issues/2405)) ([064bf3a](https://github.com/kulshekhar/ts-jest/commit/064bf3a73e9a304aa9366d27db8973b68be23ffd)), closes [#2118](https://github.com/kulshekhar/ts-jest/issues/2118)
|
|
16
229
|
|
|
17
230
|
|
|
18
231
|
|
|
@@ -173,7 +386,6 @@ export function factory(compilerInstance: TsCompilerInstance) {
|
|
|
173
386
|
|
|
174
387
|
### BREAKING CHANGES
|
|
175
388
|
|
|
176
|
-
* By default, when no `target` is defined in `tsconfig`, `ts-jest` will transform codes to ES2015 syntax
|
|
177
389
|
* Now both `isolatedModules: true` and `isolatedModule: false` codes are in one single class `TsCompiler` which is an instance created in `TsJestCompiler` based on config option `compiler` with value `typescript` or `ttypescript`.
|
|
178
390
|
|
|
179
391
|
|
|
@@ -182,11 +394,6 @@ export function factory(compilerInstance: TsCompilerInstance) {
|
|
|
182
394
|
# [27.0.0-alpha.0](https://github.com/kulshekhar/ts-jest/compare/v26.4.4...v27.0.0-alpha.0) (2020-11-11)
|
|
183
395
|
|
|
184
396
|
|
|
185
|
-
### Build System
|
|
186
|
-
|
|
187
|
-
* **devs-infra:** build package with target `es2015` ([#2130](https://github.com/kulshekhar/ts-jest/issues/2130)) ([6bd101c](https://github.com/kulshekhar/ts-jest/commit/6bd101ccde60e263352de5bee4a6bd38987eb0ca))
|
|
188
|
-
|
|
189
|
-
|
|
190
397
|
### Code Refactoring
|
|
191
398
|
|
|
192
399
|
* **config:** remove support for `astTransformers` string array ([#2129](https://github.com/kulshekhar/ts-jest/issues/2129)) ([1e0b2ce](https://github.com/kulshekhar/ts-jest/commit/1e0b2ce5599a35c108712456e455bf29c8c5fd24))
|
|
@@ -198,7 +405,6 @@ export function factory(compilerInstance: TsCompilerInstance) {
|
|
|
198
405
|
### BREAKING CHANGES
|
|
199
406
|
|
|
200
407
|
* **config:** `packageJson` config option is not used in internal `ts-jest` so this option is now removed
|
|
201
|
-
* **devs-infra:** `ts-jest` no longer ships with `es5` build but now with `es2015`
|
|
202
408
|
* **config:** One is defining ast transformers in `jest.config.js`/`package.json` should change to
|
|
203
409
|
```
|
|
204
410
|
// jest.config.js
|
package/README.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<h1 align="center">ts-jest</h1>
|
|
2
2
|
|
|
3
|
-
<p align="center">A
|
|
3
|
+
<p align="center">A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://www.npmjs.com/package/ts-jest"><img src="https://img.shields.io/npm/v/ts-jest/latest.svg?style=flat-square" alt="NPM version" /> </a>
|
|
7
|
-
<a href="https://www.npmjs.com/package/ts-jest"><img src="https://img.shields.io/npm/v/ts-jest/next.svg?style=flat-square" alt="NPM version" /> </a>
|
|
8
7
|
<a href="https://www.npmjs.com/package/ts-jest"><img src="https://img.shields.io/npm/dm/ts-jest.svg?style=flat-square" alt="NPM downloads"/> </a>
|
|
9
8
|
<a href="https://snyk.io/test/github/kulshekhar/ts-jest"><img src="https://snyk.io/test/github/kulshekhar/ts-jest/badge.svg?style=flat-square" alt="Known vulnerabilities"/> </a>
|
|
10
9
|
<a href="https://coveralls.io/github/kulshekhar/ts-jest?branch=master"><img src="https://coveralls.io/repos/github/kulshekhar/ts-jest/badge.svg?branch=master" alt="Coverage status"/> </a>
|
|
11
10
|
<a href="https://actions-badge.atrox.dev/kulshekhar/ts-jest/goto?ref=master"><img alt="GitHub actions" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fkulshekhar%2Fts-jest%2Fbadge%3Fref%3Dmaster&style=flat-square" /> </a>
|
|
12
|
-
<a href="https://github.com/kulshekhar/ts-jest/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/ts-jest.svg?style=flat-square" alt="GitHub license"/> </a>
|
|
11
|
+
<a href="https://github.com/kulshekhar/ts-jest/blob/master/LICENSE.md"><img src="https://img.shields.io/npm/l/ts-jest.svg?style=flat-square" alt="GitHub license"/> </a>
|
|
13
12
|
</p>
|
|
14
13
|
|
|
15
14
|
<img src="./icon.png" align="right" title="ts-jest Logo" width="128" height="128">
|
|
@@ -25,7 +24,7 @@ It supports all features of TypeScript including type-checking. [Read more about
|
|
|
25
24
|
|
|
26
25
|
[<img src="./website/static/img/discord.svg" align="left" height="24"> Ask for some help in the `Jest` Discord community](https://discord.gg/j6FKKQQrW9) or [`ts-jest` GitHub Discussion](https://github.com/kulshekhar/ts-jest/discussions)
|
|
27
26
|
|
|
28
|
-
[<img src="./website/static/img/troubleshooting.png" align="left" height="24"> Before reporting any
|
|
27
|
+
[<img src="./website/static/img/troubleshooting.png" align="left" height="24"> Before reporting any issues, be sure to check the troubleshooting page](TROUBLESHOOTING.md)
|
|
29
28
|
|
|
30
29
|
[<img src="./website/static/img/pull-request.png" align="left" height="24"> We're looking for collaborators! Want to help improve `ts-jest`?](https://github.com/kulshekhar/ts-jest/issues/223)
|
|
31
30
|
|
|
@@ -46,7 +45,7 @@ These instructions will get you setup to use `ts-jest` in your project. For more
|
|
|
46
45
|
|
|
47
46
|
- [TypeScript](https://www.typescriptlang.org/) - JavaScript that scales
|
|
48
47
|
- [Jest](https://jestjs.io/) - Delightful JavaScript Testing
|
|
49
|
-
- [`ts-jest`](https://kulshekhar.github.io/ts-jest) - Jest
|
|
48
|
+
- [`ts-jest`](https://kulshekhar.github.io/ts-jest) - Jest [transformer](https://jestjs.io/docs/next/code-transformation#writing-custom-transformers) for TypeScript _(yes, `ts-jest` uses itself for its tests)_
|
|
50
49
|
|
|
51
50
|
## Contributing
|
|
52
51
|
|
|
@@ -56,19 +56,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
56
56
|
to[j] = from[i];
|
|
57
57
|
return to;
|
|
58
58
|
};
|
|
59
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
60
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
61
|
+
};
|
|
59
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
63
|
exports.help = exports.run = void 0;
|
|
61
64
|
var fs_1 = require("fs");
|
|
62
65
|
var path_1 = require("path");
|
|
63
66
|
var bs_logger_1 = require("bs-logger");
|
|
64
|
-
var
|
|
67
|
+
var fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
65
68
|
var json5_1 = require("json5");
|
|
66
69
|
var backports_1 = require("../../utils/backports");
|
|
67
70
|
var presets_1 = require("../helpers/presets");
|
|
68
71
|
var run = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
72
|
var nullLogger, file, filePath, footNotes, name, isPackage, actualConfig, migratedConfig, presetName, preset, jsTransformers, jsWithTs, jsWithBabel, presetValue, migratedValue, presetValue, migratedValue, before, after, stringify, prefix;
|
|
70
|
-
var _a;
|
|
71
|
-
return __generator(this, function (
|
|
73
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
74
|
+
return __generator(this, function (_j) {
|
|
72
75
|
nullLogger = bs_logger_1.createLogger({ targets: [] });
|
|
73
76
|
file = (_a = args._[0]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
74
77
|
filePath = path_1.resolve(process.cwd(), file);
|
|
@@ -116,32 +119,32 @@ var run = function (args) { return __awaiter(void 0, void 0, void 0, function ()
|
|
|
116
119
|
presetName = "ts-jest/presets/default";
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
|
-
presetName = presetName
|
|
122
|
+
presetName = presetName !== null && presetName !== void 0 ? presetName : "ts-jest/presets/default";
|
|
120
123
|
preset = presets_1.allPresets[presetName];
|
|
121
124
|
footNotes.push("Detected preset '" + preset.label + "' as the best matching preset for your configuration.\nVisit https://kulshekhar.github.io/ts-jest/user/config/#jest-preset for more information about presets.\n");
|
|
122
125
|
}
|
|
123
|
-
else if (migratedConfig.preset
|
|
126
|
+
else if ((_b = migratedConfig.preset) === null || _b === void 0 ? void 0 : _b.startsWith('ts-jest')) {
|
|
124
127
|
if (args.jestPreset === false) {
|
|
125
128
|
delete migratedConfig.preset;
|
|
126
129
|
}
|
|
127
130
|
else {
|
|
128
|
-
preset = presets_1.allPresets[migratedConfig.preset]
|
|
131
|
+
preset = (_c = presets_1.allPresets[migratedConfig.preset]) !== null && _c !== void 0 ? _c : presets_1.defaults;
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
if (preset)
|
|
132
135
|
migratedConfig.preset = preset.name;
|
|
133
|
-
if (migratedConfig.moduleFileExtensions
|
|
134
|
-
presetValue = dedupSort(preset.value.moduleFileExtensions
|
|
136
|
+
if (((_d = migratedConfig.moduleFileExtensions) === null || _d === void 0 ? void 0 : _d.length) && preset) {
|
|
137
|
+
presetValue = dedupSort((_e = preset.value.moduleFileExtensions) !== null && _e !== void 0 ? _e : []).join('::');
|
|
135
138
|
migratedValue = dedupSort(migratedConfig.moduleFileExtensions).join('::');
|
|
136
139
|
if (presetValue === migratedValue) {
|
|
137
140
|
delete migratedConfig.moduleFileExtensions;
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
|
-
if (migratedConfig.testRegex && preset) {
|
|
141
|
-
migratedConfig.testMatch
|
|
143
|
+
if ((typeof migratedConfig.testRegex === 'string' || ((_f = migratedConfig.testRegex) === null || _f === void 0 ? void 0 : _f.length)) && preset) {
|
|
144
|
+
delete migratedConfig.testMatch;
|
|
142
145
|
}
|
|
143
|
-
else if (migratedConfig.testMatch
|
|
144
|
-
presetValue = dedupSort(preset.value.testMatch
|
|
146
|
+
else if (((_g = migratedConfig.testMatch) === null || _g === void 0 ? void 0 : _g.length) && preset) {
|
|
147
|
+
presetValue = dedupSort((_h = preset.value.testMatch) !== null && _h !== void 0 ? _h : []).join('::');
|
|
145
148
|
migratedValue = dedupSort(migratedConfig.testMatch).join('::');
|
|
146
149
|
if (presetValue === migratedValue) {
|
|
147
150
|
delete migratedConfig.testMatch;
|
|
@@ -158,13 +161,13 @@ var run = function (args) { return __awaiter(void 0, void 0, void 0, function ()
|
|
|
158
161
|
}
|
|
159
162
|
if (preset &&
|
|
160
163
|
migratedConfig.transform &&
|
|
161
|
-
|
|
164
|
+
fast_json_stable_stringify_1.default(migratedConfig.transform) === fast_json_stable_stringify_1.default(preset.value.transform)) {
|
|
162
165
|
delete migratedConfig.transform;
|
|
163
166
|
}
|
|
164
167
|
cleanupConfig(actualConfig);
|
|
165
168
|
cleanupConfig(migratedConfig);
|
|
166
|
-
before =
|
|
167
|
-
after =
|
|
169
|
+
before = fast_json_stable_stringify_1.default(actualConfig);
|
|
170
|
+
after = fast_json_stable_stringify_1.default(migratedConfig);
|
|
168
171
|
if (after === before) {
|
|
169
172
|
process.stderr.write("\nNo migration needed for given Jest configuration\n ");
|
|
170
173
|
return [2];
|
|
@@ -188,21 +191,21 @@ function cleanupConfig(config) {
|
|
|
188
191
|
if (config.globals['ts-jest'] && Object.keys(config.globals['ts-jest']).length === 0) {
|
|
189
192
|
delete config.globals['ts-jest'];
|
|
190
193
|
}
|
|
191
|
-
if (Object.keys(config.globals).length
|
|
194
|
+
if (!Object.keys(config.globals).length) {
|
|
192
195
|
delete config.globals;
|
|
193
196
|
}
|
|
194
197
|
}
|
|
195
|
-
if (config.transform && Object.keys(config.transform).length
|
|
198
|
+
if (config.transform && !Object.keys(config.transform).length) {
|
|
196
199
|
delete config.transform;
|
|
197
200
|
}
|
|
198
201
|
if (config.moduleFileExtensions) {
|
|
199
202
|
config.moduleFileExtensions = dedupSort(config.moduleFileExtensions);
|
|
200
|
-
if (config.moduleFileExtensions.length
|
|
203
|
+
if (!config.moduleFileExtensions.length)
|
|
201
204
|
delete config.moduleFileExtensions;
|
|
202
205
|
}
|
|
203
206
|
if (config.testMatch) {
|
|
204
207
|
config.testMatch = dedupSort(config.testMatch);
|
|
205
|
-
if (config.testMatch.length
|
|
208
|
+
if (!config.testMatch.length)
|
|
206
209
|
delete config.testMatch;
|
|
207
210
|
}
|
|
208
211
|
if (config.preset === "ts-jest/presets/default")
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const SOURCE_MAPPING_PREFIX = "sourceMappingURL=";
|
|
2
|
-
export declare function updateOutput(outputText: string, normalizedFileName: string, sourceMap: string): string;
|
|
2
|
+
export declare function updateOutput(outputText: string, normalizedFileName: string, sourceMap: string | undefined): string;
|
|
@@ -4,9 +4,15 @@ exports.updateOutput = exports.SOURCE_MAPPING_PREFIX = void 0;
|
|
|
4
4
|
var json_1 = require("../utils/json");
|
|
5
5
|
exports.SOURCE_MAPPING_PREFIX = 'sourceMappingURL=';
|
|
6
6
|
function updateOutput(outputText, normalizedFileName, sourceMap) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (sourceMap) {
|
|
8
|
+
var base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
|
|
9
|
+
var sourceMapContent = "data:application/json;charset=utf-8;base64," + base64Map;
|
|
10
|
+
return (outputText.slice(0, outputText.lastIndexOf(exports.SOURCE_MAPPING_PREFIX) + exports.SOURCE_MAPPING_PREFIX.length) +
|
|
11
|
+
sourceMapContent);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return outputText;
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
17
|
exports.updateOutput = updateOutput;
|
|
12
18
|
var updateSourceMap = function (sourceMapText, normalizedFileName) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from 'bs-logger';
|
|
2
2
|
import type { TranspileOutput, CompilerOptions, Program, CustomTransformers } from 'typescript';
|
|
3
|
-
import { ConfigSet } from '../config/config-set';
|
|
4
|
-
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TTypeScript } from '../types';
|
|
3
|
+
import type { ConfigSet } from '../config/config-set';
|
|
4
|
+
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript } from '../types';
|
|
5
5
|
export declare class TsCompiler implements TsCompilerInstance {
|
|
6
6
|
readonly configSet: ConfigSet;
|
|
7
7
|
readonly runtimeCacheFS: StringMap;
|
|
@@ -14,7 +14,7 @@ export declare class TsCompiler implements TsCompilerInstance {
|
|
|
14
14
|
program: Program | undefined;
|
|
15
15
|
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
|
16
16
|
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
|
17
|
-
getCompiledOutput(fileContent: string, fileName: string,
|
|
17
|
+
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): string;
|
|
18
18
|
protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput;
|
|
19
19
|
protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers;
|
|
20
20
|
}
|
|
@@ -31,6 +31,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
31
31
|
to[j] = from[i];
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
34
|
+
var __values = (this && this.__values) || function(o) {
|
|
35
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
36
|
+
if (m) return m.call(o);
|
|
37
|
+
if (o && typeof o.length === "number") return {
|
|
38
|
+
next: function () {
|
|
39
|
+
if (o && i >= o.length) o = void 0;
|
|
40
|
+
return { value: o && o[i++], done: !o };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
44
|
+
};
|
|
34
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
47
|
};
|
|
@@ -39,7 +50,6 @@ exports.TsCompiler = void 0;
|
|
|
39
50
|
var path_1 = require("path");
|
|
40
51
|
var bs_logger_1 = require("bs-logger");
|
|
41
52
|
var memoize_1 = __importDefault(require("lodash/memoize"));
|
|
42
|
-
var config_set_1 = require("../config/config-set");
|
|
43
53
|
var constants_1 = require("../constants");
|
|
44
54
|
var logger_1 = require("../utils/logger");
|
|
45
55
|
var messages_1 = require("../utils/messages");
|
|
@@ -78,59 +88,6 @@ var TsCompiler = (function () {
|
|
|
78
88
|
this._createLanguageService();
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
|
-
TsCompiler.prototype._createLanguageService = function () {
|
|
82
|
-
var _this = this;
|
|
83
|
-
this._parsedTsConfig.fileNames
|
|
84
|
-
.filter(function (fileName) {
|
|
85
|
-
var _a;
|
|
86
|
-
return !_this.configSet.isTestFile(fileName) &&
|
|
87
|
-
!fileName.includes((_a = _this._parsedTsConfig.options.outDir) !== null && _a !== void 0 ? _a : config_set_1.TS_JEST_OUT_DIR);
|
|
88
|
-
})
|
|
89
|
-
.forEach(function (fileName) { return _this._fileVersionCache.set(fileName, 0); });
|
|
90
|
-
var serviceHost = {
|
|
91
|
-
getProjectVersion: function () { return String(_this._projectVersion); },
|
|
92
|
-
getScriptFileNames: function () { return __spreadArray([], __read(_this._fileVersionCache.keys())); },
|
|
93
|
-
getScriptVersion: function (fileName) {
|
|
94
|
-
var normalizedFileName = path_1.normalize(fileName);
|
|
95
|
-
var version = _this._fileVersionCache.get(normalizedFileName);
|
|
96
|
-
return version === undefined ? undefined : String(version);
|
|
97
|
-
},
|
|
98
|
-
getScriptSnapshot: function (fileName) {
|
|
99
|
-
var _a, _b, _c, _d;
|
|
100
|
-
var normalizedFileName = path_1.normalize(fileName);
|
|
101
|
-
var hit = _this._isFileInCache(normalizedFileName);
|
|
102
|
-
_this._logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss');
|
|
103
|
-
if (!hit) {
|
|
104
|
-
var fileContent = (_d = (_b = (_a = _this._fileContentCache.get(normalizedFileName)) !== null && _a !== void 0 ? _a : _this._runtimeCacheFS.get(normalizedFileName)) !== null && _b !== void 0 ? _b : (_c = _this._cachedReadFile) === null || _c === void 0 ? void 0 : _c.call(_this, normalizedFileName)) !== null && _d !== void 0 ? _d : undefined;
|
|
105
|
-
if (fileContent) {
|
|
106
|
-
_this._fileContentCache.set(normalizedFileName, fileContent);
|
|
107
|
-
_this._fileVersionCache.set(normalizedFileName, 1);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
var contents = _this._fileContentCache.get(normalizedFileName);
|
|
111
|
-
if (contents === undefined)
|
|
112
|
-
return;
|
|
113
|
-
return _this._ts.ScriptSnapshot.fromString(contents);
|
|
114
|
-
},
|
|
115
|
-
fileExists: memoize_1.default(this._ts.sys.fileExists),
|
|
116
|
-
readFile: this._cachedReadFile,
|
|
117
|
-
readDirectory: memoize_1.default(this._ts.sys.readDirectory),
|
|
118
|
-
getDirectories: memoize_1.default(this._ts.sys.getDirectories),
|
|
119
|
-
directoryExists: memoize_1.default(this._ts.sys.directoryExists),
|
|
120
|
-
realpath: this._ts.sys.realpath && memoize_1.default(this._ts.sys.realpath),
|
|
121
|
-
getNewLine: function () { return constants_1.LINE_FEED; },
|
|
122
|
-
getCurrentDirectory: function () { return _this.configSet.cwd; },
|
|
123
|
-
getCompilationSettings: function () { return _this._compilerOptions; },
|
|
124
|
-
getDefaultLibFileName: function () { return _this._ts.getDefaultLibFilePath(_this._compilerOptions); },
|
|
125
|
-
getCustomTransformers: function () { return _this._makeTransformers(_this.configSet.resolvedTransformers); },
|
|
126
|
-
resolveModuleNames: function (moduleNames, containingFile) {
|
|
127
|
-
return moduleNames.map(function (moduleName) { return _this._resolveModuleName(moduleName, containingFile).resolvedModule; });
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
this._logger.debug('created language service');
|
|
131
|
-
this._languageService = this._ts.createLanguageService(serviceHost, this._ts.createDocumentRegistry());
|
|
132
|
-
this.program = this._languageService.getProgram();
|
|
133
|
-
};
|
|
134
91
|
TsCompiler.prototype.getResolvedModules = function (fileContent, fileName, runtimeCacheFS) {
|
|
135
92
|
var _this = this;
|
|
136
93
|
if (!this.runtimeCacheFS.size) {
|
|
@@ -140,35 +97,17 @@ var TsCompiler = (function () {
|
|
|
140
97
|
var importedModulePaths = Array.from(new Set(this._getImportedModulePaths(fileContent, fileName)));
|
|
141
98
|
this._logger.debug({ fileName: fileName }, 'getResolvedModules(): resolve nested imported module paths from directed imported module paths');
|
|
142
99
|
importedModulePaths.forEach(function (importedModulePath) {
|
|
143
|
-
var
|
|
144
|
-
var resolvedFileContent = _this._runtimeCacheFS.get(normalizedImportedModulePath);
|
|
145
|
-
if (!resolvedFileContent) {
|
|
146
|
-
resolvedFileContent = _this._moduleResolutionHost.readFile(importedModulePath);
|
|
147
|
-
_this._runtimeCacheFS.set(normalizedImportedModulePath, resolvedFileContent);
|
|
148
|
-
}
|
|
100
|
+
var resolvedFileContent = _this._getFileContentFromCache(importedModulePath);
|
|
149
101
|
importedModulePaths.push.apply(importedModulePaths, __spreadArray([], __read(_this._getImportedModulePaths(resolvedFileContent, importedModulePath).filter(function (modulePath) { return !importedModulePaths.includes(modulePath); }))));
|
|
150
102
|
});
|
|
151
103
|
return importedModulePaths;
|
|
152
104
|
};
|
|
153
|
-
TsCompiler.prototype.
|
|
154
|
-
var _this = this;
|
|
155
|
-
return this._ts
|
|
156
|
-
.preProcessFile(resolvedFileContent, true, true)
|
|
157
|
-
.importedFiles.map(function (importedFile) {
|
|
158
|
-
var resolvedModule = _this._resolveModuleName(importedFile.fileName, containingFile).resolvedModule;
|
|
159
|
-
var resolvedFileName = resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.resolvedFileName;
|
|
160
|
-
return resolvedFileName && !(resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.isExternalLibraryImport) ? resolvedFileName : '';
|
|
161
|
-
})
|
|
162
|
-
.filter(function (resolveFileName) { return !!resolveFileName; });
|
|
163
|
-
};
|
|
164
|
-
TsCompiler.prototype._resolveModuleName = function (moduleNameToResolve, containingFile) {
|
|
165
|
-
return this._ts.resolveModuleName(moduleNameToResolve, containingFile, this._compilerOptions, this._moduleResolutionHost, this._moduleResolutionCache);
|
|
166
|
-
};
|
|
167
|
-
TsCompiler.prototype.getCompiledOutput = function (fileContent, fileName, supportsStaticESM) {
|
|
105
|
+
TsCompiler.prototype.getCompiledOutput = function (fileContent, fileName, options) {
|
|
168
106
|
var moduleKind = this._initialCompilerOptions.module;
|
|
169
107
|
var esModuleInterop = this._initialCompilerOptions.esModuleInterop;
|
|
170
108
|
var allowSyntheticDefaultImports = this._initialCompilerOptions.allowSyntheticDefaultImports;
|
|
171
|
-
|
|
109
|
+
var currentModuleKind = this._compilerOptions.module;
|
|
110
|
+
if (options.supportsStaticESM && this.configSet.useESM) {
|
|
172
111
|
moduleKind =
|
|
173
112
|
!moduleKind ||
|
|
174
113
|
(moduleKind &&
|
|
@@ -185,20 +124,26 @@ var TsCompiler = (function () {
|
|
|
185
124
|
esModuleInterop: esModuleInterop, module: moduleKind });
|
|
186
125
|
if (this._languageService) {
|
|
187
126
|
this._logger.debug({ fileName: fileName }, 'getCompiledOutput(): compiling using language service');
|
|
188
|
-
this._updateMemoryCache(fileContent, fileName);
|
|
127
|
+
this._updateMemoryCache(fileContent, fileName, currentModuleKind === moduleKind);
|
|
189
128
|
var output = this._languageService.getEmitOutput(fileName);
|
|
190
|
-
this.
|
|
191
|
-
this._doTypeChecking(fileName);
|
|
129
|
+
this._doTypeChecking(fileName, options.depGraphs, options.watchMode);
|
|
192
130
|
if (output.emitSkipped) {
|
|
193
|
-
|
|
194
|
-
|
|
131
|
+
if (constants_1.TS_TSX_REGEX.test(fileName)) {
|
|
132
|
+
throw new Error(messages_1.interpolate("Unable to process '{{file}}', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform {{file}}", { file: fileName }));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this._logger.warn(messages_1.interpolate("Unable to process '{{file}}', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'`", { file: fileName }));
|
|
136
|
+
return compiler_utils_1.updateOutput(fileContent, fileName, undefined);
|
|
137
|
+
}
|
|
195
138
|
}
|
|
196
139
|
if (!output.outputFiles.length) {
|
|
197
140
|
throw new TypeError(messages_1.interpolate("Unable to require `.d.ts` file for file: {{file}}.\nThis is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `{{file}}`.", {
|
|
198
141
|
file: path_1.basename(fileName),
|
|
199
142
|
}));
|
|
200
143
|
}
|
|
201
|
-
return
|
|
144
|
+
return this._compilerOptions.sourceMap
|
|
145
|
+
? compiler_utils_1.updateOutput(output.outputFiles[1].text, fileName, output.outputFiles[0].text)
|
|
146
|
+
: compiler_utils_1.updateOutput(output.outputFiles[0].text, fileName, undefined);
|
|
202
147
|
}
|
|
203
148
|
else {
|
|
204
149
|
this._logger.debug({ fileName: fileName }, 'getCompiledOutput(): compiling as isolated module');
|
|
@@ -231,13 +176,85 @@ var TsCompiler = (function () {
|
|
|
231
176
|
}),
|
|
232
177
|
};
|
|
233
178
|
};
|
|
179
|
+
TsCompiler.prototype._createLanguageService = function () {
|
|
180
|
+
var _this = this;
|
|
181
|
+
this._parsedTsConfig.fileNames
|
|
182
|
+
.filter(function (fileName) { return constants_1.TS_TSX_REGEX.test(fileName) && !_this.configSet.isTestFile(fileName); })
|
|
183
|
+
.forEach(function (fileName) { return _this._fileVersionCache.set(fileName, 0); });
|
|
184
|
+
var serviceHost = {
|
|
185
|
+
getProjectVersion: function () { return String(_this._projectVersion); },
|
|
186
|
+
getScriptFileNames: function () { return __spreadArray([], __read(_this._fileVersionCache.keys())); },
|
|
187
|
+
getScriptVersion: function (fileName) {
|
|
188
|
+
var normalizedFileName = path_1.normalize(fileName);
|
|
189
|
+
var version = _this._fileVersionCache.get(normalizedFileName);
|
|
190
|
+
return version === undefined ? undefined : String(version);
|
|
191
|
+
},
|
|
192
|
+
getScriptSnapshot: function (fileName) {
|
|
193
|
+
var _a, _b, _c, _d;
|
|
194
|
+
var normalizedFileName = path_1.normalize(fileName);
|
|
195
|
+
var hit = _this._isFileInCache(normalizedFileName);
|
|
196
|
+
_this._logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss');
|
|
197
|
+
if (!hit) {
|
|
198
|
+
var fileContent = (_d = (_b = (_a = _this._fileContentCache.get(normalizedFileName)) !== null && _a !== void 0 ? _a : _this._runtimeCacheFS.get(normalizedFileName)) !== null && _b !== void 0 ? _b : (_c = _this._cachedReadFile) === null || _c === void 0 ? void 0 : _c.call(_this, normalizedFileName)) !== null && _d !== void 0 ? _d : undefined;
|
|
199
|
+
if (fileContent !== undefined) {
|
|
200
|
+
_this._fileContentCache.set(normalizedFileName, fileContent);
|
|
201
|
+
_this._fileVersionCache.set(normalizedFileName, 1);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
var contents = _this._fileContentCache.get(normalizedFileName);
|
|
205
|
+
if (contents === undefined)
|
|
206
|
+
return;
|
|
207
|
+
return _this._ts.ScriptSnapshot.fromString(contents);
|
|
208
|
+
},
|
|
209
|
+
fileExists: memoize_1.default(this._ts.sys.fileExists),
|
|
210
|
+
readFile: this._cachedReadFile,
|
|
211
|
+
readDirectory: memoize_1.default(this._ts.sys.readDirectory),
|
|
212
|
+
getDirectories: memoize_1.default(this._ts.sys.getDirectories),
|
|
213
|
+
directoryExists: memoize_1.default(this._ts.sys.directoryExists),
|
|
214
|
+
realpath: this._ts.sys.realpath && memoize_1.default(this._ts.sys.realpath),
|
|
215
|
+
getNewLine: function () { return constants_1.LINE_FEED; },
|
|
216
|
+
getCurrentDirectory: function () { return _this.configSet.cwd; },
|
|
217
|
+
getCompilationSettings: function () { return _this._compilerOptions; },
|
|
218
|
+
getDefaultLibFileName: function () { return _this._ts.getDefaultLibFilePath(_this._compilerOptions); },
|
|
219
|
+
getCustomTransformers: function () { return _this._makeTransformers(_this.configSet.resolvedTransformers); },
|
|
220
|
+
resolveModuleNames: function (moduleNames, containingFile) {
|
|
221
|
+
return moduleNames.map(function (moduleName) { return _this._resolveModuleName(moduleName, containingFile).resolvedModule; });
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
this._logger.debug('created language service');
|
|
225
|
+
this._languageService = this._ts.createLanguageService(serviceHost, this._ts.createDocumentRegistry());
|
|
226
|
+
this.program = this._languageService.getProgram();
|
|
227
|
+
};
|
|
228
|
+
TsCompiler.prototype._getFileContentFromCache = function (filePath) {
|
|
229
|
+
var normalizedFilePath = path_1.normalize(filePath);
|
|
230
|
+
var resolvedFileContent = this._runtimeCacheFS.get(normalizedFilePath);
|
|
231
|
+
if (!resolvedFileContent) {
|
|
232
|
+
resolvedFileContent = this._moduleResolutionHost.readFile(normalizedFilePath);
|
|
233
|
+
this._runtimeCacheFS.set(normalizedFilePath, resolvedFileContent);
|
|
234
|
+
}
|
|
235
|
+
return resolvedFileContent;
|
|
236
|
+
};
|
|
237
|
+
TsCompiler.prototype._getImportedModulePaths = function (resolvedFileContent, containingFile) {
|
|
238
|
+
var _this = this;
|
|
239
|
+
return this._ts
|
|
240
|
+
.preProcessFile(resolvedFileContent, true, true)
|
|
241
|
+
.importedFiles.map(function (importedFile) {
|
|
242
|
+
var resolvedModule = _this._resolveModuleName(importedFile.fileName, containingFile).resolvedModule;
|
|
243
|
+
var resolvedFileName = resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.resolvedFileName;
|
|
244
|
+
return resolvedFileName && !(resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.isExternalLibraryImport) ? resolvedFileName : '';
|
|
245
|
+
})
|
|
246
|
+
.filter(function (resolveFileName) { return !!resolveFileName; });
|
|
247
|
+
};
|
|
248
|
+
TsCompiler.prototype._resolveModuleName = function (moduleNameToResolve, containingFile) {
|
|
249
|
+
return this._ts.resolveModuleName(moduleNameToResolve, containingFile, this._compilerOptions, this._moduleResolutionHost, this._moduleResolutionCache);
|
|
250
|
+
};
|
|
234
251
|
TsCompiler.prototype._isFileInCache = function (fileName) {
|
|
235
252
|
return (this._fileContentCache.has(fileName) &&
|
|
236
253
|
this._fileVersionCache.has(fileName) &&
|
|
237
254
|
this._fileVersionCache.get(fileName) !== 0);
|
|
238
255
|
};
|
|
239
|
-
TsCompiler.prototype._updateMemoryCache = function (contents, fileName) {
|
|
240
|
-
|
|
256
|
+
TsCompiler.prototype._updateMemoryCache = function (contents, fileName, isModuleKindTheSame) {
|
|
257
|
+
if (isModuleKindTheSame === void 0) { isModuleKindTheSame = true; }
|
|
241
258
|
this._logger.debug({ fileName: fileName }, 'updateMemoryCache: update memory cache for language service');
|
|
242
259
|
var shouldIncrementProjectVersion = false;
|
|
243
260
|
var hit = this._isFileInCache(fileName);
|
|
@@ -246,26 +263,50 @@ var TsCompiler = (function () {
|
|
|
246
263
|
shouldIncrementProjectVersion = true;
|
|
247
264
|
}
|
|
248
265
|
else {
|
|
249
|
-
var prevVersion =
|
|
266
|
+
var prevVersion = this._fileVersionCache.get(fileName);
|
|
250
267
|
var previousContents = this._fileContentCache.get(fileName);
|
|
251
268
|
if (previousContents !== contents) {
|
|
252
269
|
this._fileVersionCache.set(fileName, prevVersion + 1);
|
|
253
270
|
this._fileContentCache.set(fileName, contents);
|
|
254
|
-
|
|
255
|
-
shouldIncrementProjectVersion = true;
|
|
271
|
+
shouldIncrementProjectVersion = true;
|
|
256
272
|
}
|
|
257
|
-
if (!this._parsedTsConfig.fileNames.includes(fileName)) {
|
|
273
|
+
if (!this._parsedTsConfig.fileNames.includes(fileName) || !isModuleKindTheSame) {
|
|
258
274
|
shouldIncrementProjectVersion = true;
|
|
259
275
|
}
|
|
260
276
|
}
|
|
261
277
|
if (shouldIncrementProjectVersion)
|
|
262
278
|
this._projectVersion++;
|
|
263
279
|
};
|
|
264
|
-
TsCompiler.prototype._doTypeChecking = function (fileName) {
|
|
280
|
+
TsCompiler.prototype._doTypeChecking = function (fileName, depGraphs, watchMode) {
|
|
281
|
+
var e_1, _a;
|
|
265
282
|
if (this.configSet.shouldReportDiagnostics(fileName)) {
|
|
266
|
-
|
|
283
|
+
this._logger.debug({ fileName: fileName }, '_doTypeChecking(): computing diagnostics using language service');
|
|
284
|
+
var diagnostics = __spreadArray(__spreadArray([], __read(this._languageService.getSemanticDiagnostics(fileName))), __read(this._languageService.getSyntacticDiagnostics(fileName)));
|
|
267
285
|
this.configSet.raiseDiagnostics(diagnostics, fileName, this._logger);
|
|
268
286
|
}
|
|
287
|
+
if (watchMode) {
|
|
288
|
+
this._logger.debug({ fileName: fileName }, '_doTypeChecking(): starting watch mode computing diagnostics');
|
|
289
|
+
try {
|
|
290
|
+
for (var _b = __values(depGraphs.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
291
|
+
var entry = _c.value;
|
|
292
|
+
var normalizedModuleNames = entry[1].resolvedModuleNames.map(function (moduleName) { return path_1.normalize(moduleName); });
|
|
293
|
+
var fileToReTypeCheck = entry[0];
|
|
294
|
+
if (normalizedModuleNames.includes(fileName) && this.configSet.shouldReportDiagnostics(fileToReTypeCheck)) {
|
|
295
|
+
this._logger.debug({ fileToReTypeCheck: fileToReTypeCheck }, '_doTypeChecking(): computing diagnostics using language service');
|
|
296
|
+
this._updateMemoryCache(this._getFileContentFromCache(fileToReTypeCheck), fileToReTypeCheck);
|
|
297
|
+
var importedModulesDiagnostics = __spreadArray(__spreadArray([], __read(this._languageService.getSemanticDiagnostics(fileToReTypeCheck))), __read(this._languageService.getSyntacticDiagnostics(fileToReTypeCheck)));
|
|
298
|
+
this.configSet.raiseDiagnostics(importedModulesDiagnostics, fileName, this._logger);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
303
|
+
finally {
|
|
304
|
+
try {
|
|
305
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
306
|
+
}
|
|
307
|
+
finally { if (e_1) throw e_1.error; }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
269
310
|
};
|
|
270
311
|
return TsCompiler;
|
|
271
312
|
}());
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ConfigSet } from '../config/config-set';
|
|
2
|
+
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../types';
|
|
3
|
+
export declare class TsJestCompiler implements CompilerInstance {
|
|
4
|
+
private readonly _compilerInstance;
|
|
5
|
+
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
|
6
|
+
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
|
7
|
+
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): string;
|
|
8
|
+
}
|
|
@@ -9,8 +9,8 @@ var TsJestCompiler = (function () {
|
|
|
9
9
|
TsJestCompiler.prototype.getResolvedModules = function (fileContent, fileName, runtimeCacheFS) {
|
|
10
10
|
return this._compilerInstance.getResolvedModules(fileContent, fileName, runtimeCacheFS);
|
|
11
11
|
};
|
|
12
|
-
TsJestCompiler.prototype.getCompiledOutput = function (fileContent, fileName,
|
|
13
|
-
return this._compilerInstance.getCompiledOutput(fileContent, fileName,
|
|
12
|
+
TsJestCompiler.prototype.getCompiledOutput = function (fileContent, fileName, options) {
|
|
13
|
+
return this._compilerInstance.getCompiledOutput(fileContent, fileName, options);
|
|
14
14
|
};
|
|
15
15
|
return TsJestCompiler;
|
|
16
16
|
}());
|
|
@@ -115,9 +115,7 @@ var ConfigSet = (function () {
|
|
|
115
115
|
};
|
|
116
116
|
this.useESM = false;
|
|
117
117
|
this._overriddenCompilerOptions = {
|
|
118
|
-
sourceMap: true,
|
|
119
118
|
inlineSourceMap: false,
|
|
120
|
-
inlineSources: true,
|
|
121
119
|
declaration: false,
|
|
122
120
|
noEmit: false,
|
|
123
121
|
removeComments: false,
|
|
@@ -184,7 +182,7 @@ var ConfigSet = (function () {
|
|
|
184
182
|
this.logger.debug({ babelConfig: this.babelConfig }, 'normalized babel config via ts-jest option');
|
|
185
183
|
this.babelJestTransformer = importer_1.importer
|
|
186
184
|
.babelJest("Using \"babel-jest\" requires this package to be installed.")
|
|
187
|
-
.createTransformer(this.babelConfig);
|
|
185
|
+
.default.createTransformer(this.babelConfig);
|
|
188
186
|
this.logger.debug('created babel-jest transformer');
|
|
189
187
|
}
|
|
190
188
|
var diagnosticsOpt = (_b = options.diagnostics) !== null && _b !== void 0 ? _b : true;
|
|
@@ -209,9 +207,9 @@ var ConfigSet = (function () {
|
|
|
209
207
|
throws: diagnosticsOpt,
|
|
210
208
|
};
|
|
211
209
|
}
|
|
212
|
-
this.
|
|
210
|
+
this._shouldIgnoreDiagnosticsForFile = this._diagnostics.exclude.length
|
|
213
211
|
? jest_util_1.globsToMatcher(this._diagnostics.exclude)
|
|
214
|
-
: function () { return
|
|
212
|
+
: function () { return false; };
|
|
215
213
|
this.logger.debug({ diagnostics: this._diagnostics }, 'normalized diagnostics config via ts-jest option');
|
|
216
214
|
var tsconfigOpt = options.tsconfig;
|
|
217
215
|
var configFilePath = typeof tsconfigOpt === 'string' ? this.resolvePath(tsconfigOpt) : undefined;
|
|
@@ -275,7 +273,7 @@ var ConfigSet = (function () {
|
|
|
275
273
|
};
|
|
276
274
|
ConfigSet.prototype._getAndResolveTsConfig = function (compilerOptions, resolvedConfigFile) {
|
|
277
275
|
var e_2, _a, _b;
|
|
278
|
-
var _c, _d;
|
|
276
|
+
var _c, _d, _e;
|
|
279
277
|
var result = this._resolveTsConfig(compilerOptions, resolvedConfigFile);
|
|
280
278
|
var forcedOptions = this._overriddenCompilerOptions;
|
|
281
279
|
var finalOptions = result.options;
|
|
@@ -306,8 +304,8 @@ var ConfigSet = (function () {
|
|
|
306
304
|
finalOptions.outDir = exports.TS_JEST_OUT_DIR;
|
|
307
305
|
}
|
|
308
306
|
try {
|
|
309
|
-
for (var
|
|
310
|
-
var key =
|
|
307
|
+
for (var _f = __values(Object.keys(forcedOptions)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
308
|
+
var key = _g.value;
|
|
311
309
|
var val = forcedOptions[key];
|
|
312
310
|
if (val === undefined) {
|
|
313
311
|
delete finalOptions[key];
|
|
@@ -320,7 +318,7 @@ var ConfigSet = (function () {
|
|
|
320
318
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
321
319
|
finally {
|
|
322
320
|
try {
|
|
323
|
-
if (
|
|
321
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
324
322
|
}
|
|
325
323
|
finally { if (e_2) throw e_2.error; }
|
|
326
324
|
}
|
|
@@ -342,7 +340,9 @@ var ConfigSet = (function () {
|
|
|
342
340
|
});
|
|
343
341
|
this.logger.warn(message);
|
|
344
342
|
}
|
|
345
|
-
|
|
343
|
+
var resultOptions = result.options;
|
|
344
|
+
var sourceMap = (_d = resultOptions.sourceMap) !== null && _d !== void 0 ? _d : true;
|
|
345
|
+
return __assign(__assign({}, result), { options: __assign(__assign({}, resultOptions), { sourceMap: sourceMap, inlineSources: sourceMap, module: (_e = resultOptions.module) !== null && _e !== void 0 ? _e : this.compilerModule.ModuleKind.CommonJS }) });
|
|
346
346
|
};
|
|
347
347
|
ConfigSet.prototype._resolveTsConfig = function (compilerOptions, resolvedConfigFile) {
|
|
348
348
|
var config = { compilerOptions: Object.create(null) };
|
|
@@ -397,8 +397,8 @@ var ConfigSet = (function () {
|
|
|
397
397
|
ConfigSet.prototype.shouldReportDiagnostics = function (filePath) {
|
|
398
398
|
var fileExtension = path_1.extname(filePath);
|
|
399
399
|
return constants_1.JS_JSX_EXTENSIONS.includes(fileExtension)
|
|
400
|
-
? this.parsedTsConfig.options.checkJs && this.
|
|
401
|
-
: this.
|
|
400
|
+
? this.parsedTsConfig.options.checkJs && !this._shouldIgnoreDiagnosticsForFile(filePath)
|
|
401
|
+
: !this._shouldIgnoreDiagnosticsForFile(filePath);
|
|
402
402
|
};
|
|
403
403
|
ConfigSet.prototype._createTsError = function (diagnostics) {
|
|
404
404
|
var _this = this;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTransformer = void 0;
|
|
4
3
|
var ts_jest_transformer_1 = require("./ts-jest-transformer");
|
|
5
|
-
|
|
6
|
-
return new ts_jest_transformer_1.TsJestTransformer();
|
|
7
|
-
}
|
|
8
|
-
exports.createTransformer = createTransformer;
|
|
4
|
+
exports.default = {
|
|
5
|
+
createTransformer: function () { return new ts_jest_transformer_1.TsJestTransformer(); },
|
|
6
|
+
};
|
|
@@ -5,6 +5,7 @@ export interface RawCompilerOptions {
|
|
|
5
5
|
declarationDir?: string | null;
|
|
6
6
|
diagnostics?: boolean;
|
|
7
7
|
disableReferencedProjectLoad?: boolean;
|
|
8
|
+
noPropertyAccessFromIndexSignature?: boolean;
|
|
8
9
|
emitBOM?: boolean;
|
|
9
10
|
emitDeclarationOnly?: boolean;
|
|
10
11
|
incremental?: boolean;
|
|
@@ -18,9 +19,9 @@ export interface RawCompilerOptions {
|
|
|
18
19
|
jsxImportSource?: string;
|
|
19
20
|
listFiles?: boolean;
|
|
20
21
|
mapRoot?: string;
|
|
21
|
-
module?: 'CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | string;
|
|
22
|
-
moduleResolution?: 'Classic' | 'Node';
|
|
23
|
-
newLine?: 'crlf' | 'lf';
|
|
22
|
+
module?: ('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None') | string;
|
|
23
|
+
moduleResolution?: ('Classic' | 'Node') | string;
|
|
24
|
+
newLine?: ('crlf' | 'lf') | string;
|
|
24
25
|
noEmit?: boolean;
|
|
25
26
|
noEmitHelpers?: boolean;
|
|
26
27
|
noEmitOnError?: boolean;
|
|
@@ -46,7 +47,7 @@ export interface RawCompilerOptions {
|
|
|
46
47
|
sourceRoot?: string;
|
|
47
48
|
suppressExcessPropertyErrors?: boolean;
|
|
48
49
|
suppressImplicitAnyIndexErrors?: boolean;
|
|
49
|
-
target?: 'ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ESNext' | string;
|
|
50
|
+
target?: ('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ESNext') | string;
|
|
50
51
|
watch?: boolean;
|
|
51
52
|
fallbackPolling?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling';
|
|
52
53
|
watchDirectory?: 'useFsEvents' | 'fixedPollingInterval' | 'dynamicPriorityPolling';
|
|
@@ -78,7 +79,7 @@ export interface RawCompilerOptions {
|
|
|
78
79
|
noImplicitUseStrict?: boolean;
|
|
79
80
|
listEmittedFiles?: boolean;
|
|
80
81
|
disableSizeLimit?: boolean;
|
|
81
|
-
lib?: Array<'ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.ImportScripts'>;
|
|
82
|
+
lib?: Array<('ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.ImportScripts') | string>;
|
|
82
83
|
strictNullChecks?: boolean;
|
|
83
84
|
maxNodeModuleJsDepth?: number;
|
|
84
85
|
importHelpers?: boolean;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SyncTransformer, TransformedSource } from '@jest/transform';
|
|
2
2
|
import type { Config } from '@jest/types';
|
|
3
|
-
import { TsJestCompiler } from './compiler/ts-jest-compiler';
|
|
4
3
|
import { ConfigSet } from './config/config-set';
|
|
5
|
-
import type { ProjectConfigTsJest, TransformOptionsTsJest } from './types';
|
|
6
|
-
export declare class TsJestTransformer implements
|
|
4
|
+
import type { CompilerInstance, ProjectConfigTsJest, TransformOptionsTsJest } from './types';
|
|
5
|
+
export declare class TsJestTransformer implements SyncTransformer {
|
|
7
6
|
private readonly _logger;
|
|
8
|
-
protected _compiler:
|
|
7
|
+
protected _compiler: CompilerInstance;
|
|
9
8
|
private _tsResolvedModulesCachePath;
|
|
10
9
|
private _transformCfgStr;
|
|
11
10
|
private _depGraphs;
|
|
11
|
+
private _watchMode;
|
|
12
12
|
constructor();
|
|
13
13
|
private _configsFor;
|
|
14
14
|
protected _createConfigSet(config: ProjectConfigTsJest | undefined): ConfigSet;
|
|
@@ -53,8 +53,11 @@ exports.CACHE_KEY_EL_SEPARATOR = '\x00';
|
|
|
53
53
|
var TsJestTransformer = (function () {
|
|
54
54
|
function TsJestTransformer() {
|
|
55
55
|
this._depGraphs = new Map();
|
|
56
|
+
this._watchMode = false;
|
|
56
57
|
this._logger = logger_1.rootLogger.child({ namespace: 'ts-jest-transformer' });
|
|
57
58
|
version_checkers_1.VersionCheckers.jest.warn();
|
|
59
|
+
this.getCacheKey = this.getCacheKey.bind(this);
|
|
60
|
+
this.process = this.process.bind(this);
|
|
58
61
|
this._logger.debug('created new transformer');
|
|
59
62
|
}
|
|
60
63
|
TsJestTransformer.prototype._configsFor = function (transformOptions) {
|
|
@@ -66,6 +69,7 @@ var TsJestTransformer = (function () {
|
|
|
66
69
|
this._compiler = ccs.compiler;
|
|
67
70
|
this._depGraphs = ccs.depGraphs;
|
|
68
71
|
this._tsResolvedModulesCachePath = ccs.tsResolvedModulesCachePath;
|
|
72
|
+
this._watchMode = ccs.watchMode;
|
|
69
73
|
configSet = ccs.configSet;
|
|
70
74
|
}
|
|
71
75
|
else {
|
|
@@ -77,6 +81,7 @@ var TsJestTransformer = (function () {
|
|
|
77
81
|
this._compiler = serializedCcs.compiler;
|
|
78
82
|
this._depGraphs = serializedCcs.depGraphs;
|
|
79
83
|
this._tsResolvedModulesCachePath = serializedCcs.tsResolvedModulesCachePath;
|
|
84
|
+
this._watchMode = serializedCcs.watchMode;
|
|
80
85
|
configSet = serializedCcs.configSet;
|
|
81
86
|
}
|
|
82
87
|
else {
|
|
@@ -88,6 +93,7 @@ var TsJestTransformer = (function () {
|
|
|
88
93
|
this._transformCfgStr = "" + new jsonable_value_1.JsonableValue(jest_1).serialized + configSet.cacheSuffix;
|
|
89
94
|
this._createCompiler(configSet, cacheFS);
|
|
90
95
|
this._getFsCachedResolvedModules(configSet);
|
|
96
|
+
this._watchMode = process.argv.includes('--watch');
|
|
91
97
|
TsJestTransformer._cachedConfigSets.push({
|
|
92
98
|
jestConfig: new jsonable_value_1.JsonableValue(config),
|
|
93
99
|
configSet: configSet,
|
|
@@ -95,6 +101,7 @@ var TsJestTransformer = (function () {
|
|
|
95
101
|
compiler: this._compiler,
|
|
96
102
|
depGraphs: this._depGraphs,
|
|
97
103
|
tsResolvedModulesCachePath: this._tsResolvedModulesCachePath,
|
|
104
|
+
watchMode: this._watchMode,
|
|
98
105
|
});
|
|
99
106
|
}
|
|
100
107
|
}
|
|
@@ -136,7 +143,11 @@ var TsJestTransformer = (function () {
|
|
|
136
143
|
result = fileContent;
|
|
137
144
|
}
|
|
138
145
|
else if (isJsFile || isTsFile) {
|
|
139
|
-
result = this._compiler.getCompiledOutput(fileContent, filePath,
|
|
146
|
+
result = this._compiler.getCompiledOutput(fileContent, filePath, {
|
|
147
|
+
depGraphs: this._depGraphs,
|
|
148
|
+
supportsStaticESM: transformOptions.supportsStaticESM,
|
|
149
|
+
watchMode: this._watchMode,
|
|
150
|
+
});
|
|
140
151
|
}
|
|
141
152
|
else {
|
|
142
153
|
var message = babelJest ? "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files." : "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore.";
|
package/dist/types.d.ts
CHANGED
|
@@ -57,13 +57,19 @@ export interface GlobalConfigTsJest extends Config.ConfigGlobals {
|
|
|
57
57
|
export interface InitialOptionsTsJest extends Config.InitialOptions {
|
|
58
58
|
globals?: GlobalConfigTsJest;
|
|
59
59
|
}
|
|
60
|
+
export declare type StringMap = Map<string, string>;
|
|
60
61
|
export interface DepGraphInfo {
|
|
61
62
|
fileContent: string;
|
|
62
63
|
resolvedModuleNames: string[];
|
|
63
64
|
}
|
|
65
|
+
export interface TsJestCompileOptions {
|
|
66
|
+
depGraphs: Map<string, DepGraphInfo>;
|
|
67
|
+
watchMode: boolean;
|
|
68
|
+
supportsStaticESM: boolean;
|
|
69
|
+
}
|
|
64
70
|
export interface CompilerInstance {
|
|
65
71
|
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
|
66
|
-
getCompiledOutput(fileContent: string, fileName: string,
|
|
72
|
+
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): string;
|
|
67
73
|
}
|
|
68
74
|
export interface TsCompilerInstance extends CompilerInstance {
|
|
69
75
|
configSet: ConfigSet;
|
package/dist/utils/json.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.normalize = exports.parse = exports.stringify = void 0;
|
|
4
|
-
var
|
|
7
|
+
var fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
5
8
|
var UNDEFINED = 'undefined';
|
|
6
9
|
function stringify(input) {
|
|
7
|
-
return input === undefined ? UNDEFINED :
|
|
10
|
+
return input === undefined ? UNDEFINED : fast_json_stable_stringify_1.default(input);
|
|
8
11
|
}
|
|
9
12
|
exports.stringify = stringify;
|
|
10
13
|
function parse(input) {
|
|
@@ -7,9 +7,9 @@ var logger_1 = require("./logger");
|
|
|
7
7
|
var messages_1 = require("./messages");
|
|
8
8
|
var logger = logger_1.rootLogger.child({ namespace: 'versions' });
|
|
9
9
|
exports.VersionCheckers = {
|
|
10
|
-
jest: createVersionChecker('jest', ">=27.0.0
|
|
10
|
+
jest: createVersionChecker('jest', ">=27.0.0 <28"),
|
|
11
11
|
typescript: createVersionChecker('typescript', ">=3.8 <5"),
|
|
12
|
-
babelJest: createVersionChecker('babel-jest', ">=27.0.0
|
|
12
|
+
babelJest: createVersionChecker('babel-jest', ">=27.0.0 <28"),
|
|
13
13
|
babelCore: createVersionChecker('@babel/core', ">=7.0.0-beta.0 <8"),
|
|
14
14
|
};
|
|
15
15
|
function checkVersion(name, expectedRange, action) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./dist/*": "./dist/*.js",
|
|
9
|
+
"./jest-preset": "./jest-preset.js",
|
|
10
|
+
"./presets": "./presets/index.js",
|
|
11
|
+
"./utils": "./utils/index.js",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
6
14
|
"bin": {
|
|
7
15
|
"ts-jest": "cli.js"
|
|
8
16
|
},
|
|
9
|
-
"description": "A
|
|
17
|
+
"description": "A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript",
|
|
10
18
|
"scripts": {
|
|
11
19
|
"prebuild": "node scripts/pre-build.js",
|
|
12
20
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -21,9 +29,8 @@
|
|
|
21
29
|
"test:external-repos": "npm run test:external external-repos",
|
|
22
30
|
"lint": "node_modules/.bin/eslint --ext .js,.ts .",
|
|
23
31
|
"lint:fix": "node_modules/.bin/eslint --fix --ext .js,.ts .",
|
|
24
|
-
"lint:prettier": "prettier '**/*.{yml,yaml}' 'website/**/*.{css,js,md}' 'CONTRIBUTING.md' 'README.md' 'TROUBLESHOOTING.md'",
|
|
25
|
-
"lint:prettier-
|
|
26
|
-
"lint:prettier-ci": "yarn lint:prettier --check --ignore-path .gitignore",
|
|
32
|
+
"lint:prettier": "prettier 'scripts/**' '**/*.{yml,yaml}' 'website/**/*.{css,js,md}' 'CONTRIBUTING.md' 'README.md' 'TROUBLESHOOTING.md' --write --ignore-path .gitignore",
|
|
33
|
+
"lint:prettier-ci": "prettier 'scripts/**' '**/*.{yml,yaml}' 'website/**/*.{css,js,md}' 'CONTRIBUTING.md' 'README.md' 'TROUBLESHOOTING.md' --check --ignore-path .gitignore",
|
|
27
34
|
"doc": "cd website && npm run start",
|
|
28
35
|
"doc:build": "cd website && npm run build",
|
|
29
36
|
"changelog": "node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
|
@@ -60,7 +67,7 @@
|
|
|
60
67
|
"bs-logger": "0.x",
|
|
61
68
|
"buffer-from": "1.x",
|
|
62
69
|
"fast-json-stable-stringify": "2.x",
|
|
63
|
-
"jest-util": "
|
|
70
|
+
"jest-util": "^27.0.0",
|
|
64
71
|
"json5": "2.x",
|
|
65
72
|
"lodash": "4.x",
|
|
66
73
|
"make-error": "1.x",
|
|
@@ -69,7 +76,7 @@
|
|
|
69
76
|
"yargs-parser": "20.x"
|
|
70
77
|
},
|
|
71
78
|
"peerDependencies": {
|
|
72
|
-
"jest": "27.0.0
|
|
79
|
+
"jest": "^27.0.0",
|
|
73
80
|
"typescript": ">=3.8 <5.0"
|
|
74
81
|
},
|
|
75
82
|
"husky": {
|
|
@@ -82,8 +89,8 @@
|
|
|
82
89
|
"devDependencies": {
|
|
83
90
|
"@commitlint/cli": "12.x",
|
|
84
91
|
"@commitlint/config-angular": "^12.0.0",
|
|
85
|
-
"@jest/transform": "
|
|
86
|
-
"@jest/types": "
|
|
92
|
+
"@jest/transform": "^27.0.0",
|
|
93
|
+
"@jest/types": "^27.0.0",
|
|
87
94
|
"@types/babel__core": "7.x",
|
|
88
95
|
"@types/buffer-from": "latest",
|
|
89
96
|
"@types/cross-spawn": "latest",
|
|
@@ -93,7 +100,7 @@
|
|
|
93
100
|
"@types/lodash": "4.x",
|
|
94
101
|
"@types/micromatch": "4.x",
|
|
95
102
|
"@types/mkdirp": "latest",
|
|
96
|
-
"@types/node": "14.
|
|
103
|
+
"@types/node": "14.14.43",
|
|
97
104
|
"@types/node-fetch": "^2.5.8",
|
|
98
105
|
"@types/react": "17.x",
|
|
99
106
|
"@types/semver": "latest",
|
|
@@ -111,16 +118,17 @@
|
|
|
111
118
|
"eslint-plugin-prefer-arrow": "latest",
|
|
112
119
|
"eslint-plugin-prettier": "latest",
|
|
113
120
|
"execa": "latest",
|
|
114
|
-
"fs-extra": "
|
|
121
|
+
"fs-extra": "10.x",
|
|
122
|
+
"glob": "^7.1.7",
|
|
115
123
|
"glob-gitignore": "latest",
|
|
116
124
|
"husky": "4.x",
|
|
117
|
-
"jest": "
|
|
125
|
+
"jest": "^27.0.0",
|
|
118
126
|
"js-yaml": "latest",
|
|
119
|
-
"json-schema-to-typescript": "^10.1.
|
|
127
|
+
"json-schema-to-typescript": "^10.1.4",
|
|
120
128
|
"lint-staged": "latest",
|
|
121
129
|
"node-fetch": "^2.6.1",
|
|
122
130
|
"npm-run-all": "latest",
|
|
123
|
-
"prettier": "2.
|
|
131
|
+
"prettier": "2.3.0",
|
|
124
132
|
"source-map": "latest",
|
|
125
133
|
"typescript": "^4.1.2"
|
|
126
134
|
},
|
|
@@ -131,6 +139,6 @@
|
|
|
131
139
|
]
|
|
132
140
|
},
|
|
133
141
|
"engines": {
|
|
134
|
-
"node": ">=
|
|
142
|
+
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
|
|
135
143
|
}
|
|
136
144
|
}
|