ts-jest 26.5.6 → 27.0.0-next.11

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.
Files changed (50) hide show
  1. package/.ts-jest-digest +1 -1
  2. package/CHANGELOG.md +254 -6
  3. package/CONTRIBUTING.md +10 -10
  4. package/README.md +21 -21
  5. package/cli.js +0 -0
  6. package/dist/cli/config/init.js +5 -3
  7. package/dist/cli/config/migrate.js +18 -12
  8. package/dist/cli/help.js +2 -1
  9. package/dist/compiler/{instance.d.ts → compiler-utils.d.ts} +0 -0
  10. package/dist/compiler/compiler-utils.js +18 -0
  11. package/dist/compiler/ts-compiler.d.ts +20 -0
  12. package/dist/compiler/ts-compiler.js +309 -0
  13. package/dist/compiler/ts-jest-compiler.d.ts +8 -0
  14. package/dist/compiler/ts-jest-compiler.js +17 -0
  15. package/dist/config/config-set.d.ts +10 -10
  16. package/dist/config/config-set.js +125 -205
  17. package/dist/config/paths-to-module-name-mapper.js +6 -5
  18. package/dist/constants.d.ts +4 -1
  19. package/dist/constants.js +5 -2
  20. package/dist/index.d.ts +4 -18
  21. package/dist/index.js +2 -20
  22. package/dist/presets/create-jest-preset.d.ts +1 -5
  23. package/dist/presets/create-jest-preset.js +7 -5
  24. package/dist/{tsconfig-raw.d.ts → raw-compiler-options.d.ts} +8 -7
  25. package/dist/{tsconfig-raw.js → raw-compiler-options.js} +0 -0
  26. package/dist/transformers/hoist-jest.js +13 -12
  27. package/dist/transformers/path-mapping.d.ts +2 -2
  28. package/dist/transformers/path-mapping.js +9 -10
  29. package/dist/ts-jest-transformer.d.ts +15 -8
  30. package/dist/ts-jest-transformer.js +147 -37
  31. package/dist/types.d.ts +56 -18
  32. package/dist/utils/backports.js +12 -12
  33. package/dist/utils/importer.js +8 -7
  34. package/dist/utils/json.js +6 -3
  35. package/dist/utils/ts-error.js +3 -1
  36. package/dist/utils/version-checkers.js +2 -2
  37. package/package.json +31 -23
  38. package/presets/default-esm/jest-preset.js +1 -0
  39. package/presets/index.d.ts +6 -3
  40. package/presets/index.js +21 -9
  41. package/presets/js-with-babel-esm/jest-preset.js +1 -0
  42. package/presets/js-with-ts-esm/jest-preset.js +1 -0
  43. package/utils/index.js +1 -1
  44. package/dist/compiler/instance.js +0 -55
  45. package/dist/compiler/language-service.d.ts +0 -1
  46. package/dist/compiler/language-service.js +0 -286
  47. package/dist/compiler/transpiler.d.ts +0 -1
  48. package/dist/compiler/transpiler.js +0 -24
  49. package/dist/transformers/index.d.ts +0 -1
  50. package/dist/transformers/index.js +0 -24
package/.ts-jest-digest CHANGED
@@ -1 +1 @@
1
- 23a45c3c610603c5fb7b5956ee7a94657fb32b21
1
+ 3ad850149c559ab49c38058fce70e05ddfded621
package/CHANGELOG.md CHANGED
@@ -1,18 +1,59 @@
1
- ## [26.5.6](https://github.com/kulshekhar/ts-jest/compare/v26.5.5...v26.5.6) (2021-05-05)
1
+ ## [26.5.5](https://github.com/kulshekhar/ts-jest/compare/v26.5.4...v26.5.5) (2021-04-15)
2
2
 
3
3
 
4
- ### Code Refactoring
4
+ ### Bug Fixes
5
5
 
6
- * 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)).
6
+ * **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)
7
7
 
8
8
 
9
9
 
10
- ## [26.5.5](https://github.com/kulshekhar/ts-jest/compare/v26.5.4...v26.5.5) (2021-04-15)
10
+ # [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)
11
11
 
12
12
 
13
13
  ### Bug Fixes
14
14
 
15
- * **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)
15
+ * **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)
16
+
17
+
18
+ ### Features
19
+
20
+ * support jest **27.0.0-next.7** ([#2498](https://github.com/kulshekhar/ts-jest/issues/2498)) ([a10af91](https://github.com/kulshekhar/ts-jest/commit/a10af91e2c3128c8de732a421f743621e60dbe8e))
21
+ * support jest **27.0.0-next.8** ([#2512](https://github.com/kulshekhar/ts-jest/issues/2512)) ([999ef60](https://github.com/kulshekhar/ts-jest/commit/999ef60c93801de5cdb1a3483af16090e3a1b52e))
22
+
23
+
24
+
25
+ # [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)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **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)
31
+ * declare missing export for `jest-preset` ([#2477](https://github.com/kulshekhar/ts-jest/issues/2477)) ([fc3da9b](https://github.com/kulshekhar/ts-jest/commit/fc3da9b09e366c5491633d7bf0545716531f6d76))
32
+
33
+
34
+ ### Features
35
+
36
+ * support jest **27.0.0-next.6** ([#2476](https://github.com/kulshekhar/ts-jest/issues/2476)) ([6452e30](https://github.com/kulshekhar/ts-jest/commit/6452e30e818c303018b2c21aba4d4c5f901f3e63))
37
+
38
+
39
+ ## BREAKING CHANGES
40
+
41
+ * follow Jest node engines ([#2478](https://github.com/kulshekhar/ts-jest/pull/2478)) ([1fecf7f](https://github.com/kulshekhar/ts-jest/commit/1fecf7ff92a5f1a0cc6ea1d27026f9f54a3d5ead))
42
+ * 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))
43
+
44
+
45
+
46
+ # [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)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **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)
52
+
53
+
54
+ ### Features
55
+
56
+ * adopt `jest@27.0.0-next.5` ([#2450](https://github.com/kulshekhar/ts-jest/issues/2450)) ([b714da3](https://github.com/kulshekhar/ts-jest/commit/b714da36e2cb9fa7cc22591b12f301d904334a3f)), closes [#2459](https://github.com/kulshekhar/ts-jest/issues/2459)
16
57
 
17
58
 
18
59
 
@@ -25,6 +66,24 @@
25
66
 
26
67
 
27
68
 
69
+ # [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)
70
+
71
+
72
+ ### Bug Fixes
73
+
74
+ * **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)
75
+ * **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)
76
+ * 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)
77
+ * **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)
78
+ * **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)
79
+
80
+
81
+ ### Features
82
+
83
+ * adopt jest **27.0.0-next.4** ([#2435](https://github.com/kulshekhar/ts-jest/issues/2435)) ([1d411f2](https://github.com/kulshekhar/ts-jest/commit/1d411f285e4f7eff7982c3917b6b91b5af617e8a))
84
+
85
+
86
+
28
87
  ## [26.5.3](https://github.com/kulshekhar/ts-jest/compare/v26.5.2...v26.5.3) (2021-03-03)
29
88
 
30
89
 
@@ -36,6 +95,18 @@
36
95
 
37
96
 
38
97
 
98
+ # [27.0.0-next.7](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.6...v27.0.0-next.7) (2021-02-24)
99
+
100
+
101
+ ### Bug Fixes
102
+
103
+ * **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)
104
+ * **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))
105
+ * **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)
106
+ * **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)
107
+
108
+
109
+
39
110
  ## [26.5.2](https://github.com/kulshekhar/ts-jest/compare/v26.5.1...v26.5.2) (2021-02-21)
40
111
 
41
112
 
@@ -43,10 +114,25 @@
43
114
 
44
115
  * **compiler:** exclude files in `outDir` from compiler source files ([#2376](https://github.com/kulshekhar/ts-jest/issues/2376)) ([9034677](https://github.com/kulshekhar/ts-jest/commit/9034677f9ce0968339d3d942a70e888996fac532)), closes [#2350](https://github.com/kulshekhar/ts-jest/issues/2350) [#2374](https://github.com/kulshekhar/ts-jest/issues/2374)
45
116
  * **config:** define `matchTestFilePath` before `setupTsJestCfg` ([#2373](https://github.com/kulshekhar/ts-jest/issues/2373)) ([c427fea](https://github.com/kulshekhar/ts-jest/commit/c427fea48a24b5ce6e8b9260d3c322583b062a77)), closes [#2371](https://github.com/kulshekhar/ts-jest/issues/2371)
46
- * **config:** improve emit skipped error message and ensure `outDir` always `TS_JEST_OUT_DIR` ([#2357](https://github.com/kulshekhar/ts-jest/issues/2357)) ([f2808bb](https://github.com/kulshekhar/ts-jest/commit/f2808bb0b15231c67ccb9a97ed606741213c03e6))
117
+ * **config:** improve emit skipped error message ([#2357](https://github.com/kulshekhar/ts-jest/issues/2357)) ([f2808bb](https://github.com/kulshekhar/ts-jest/commit/f2808bb0b15231c67ccb9a97ed606741213c03e6))
47
118
  * **typings:** set correct typing for `tsconfig`/`tsConfig` option ([#2377](https://github.com/kulshekhar/ts-jest/issues/2377)) ([d4f6aff](https://github.com/kulshekhar/ts-jest/commit/d4f6aff3f181761bf25c64ff1a97dd19a69196f9)), closes [#2368](https://github.com/kulshekhar/ts-jest/issues/2368)
48
119
 
49
120
 
121
+ # [27.0.0-next.6](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.5...v27.0.0-next.6) (2021-02-11)
122
+
123
+
124
+ ### Bug Fixes
125
+
126
+ * **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))
127
+
128
+
129
+ ### Features
130
+
131
+ * **compiler:** expose `TsCompiler` as public api ([#2344](https://github.com/kulshekhar/ts-jest/issues/2344)) ([871cd6a](https://github.com/kulshekhar/ts-jest/commit/871cd6a3abb10569a04d05f72bbb41c952665ed4))
132
+ * **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))
133
+ * **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))
134
+
135
+
50
136
 
51
137
  ## [26.5.1](https://github.com/kulshekhar/ts-jest/compare/v26.5.0...v26.5.1) (2021-02-09)
52
138
 
@@ -58,6 +144,27 @@
58
144
 
59
145
 
60
146
 
147
+ # [27.0.0-next.5](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.4...v27.0.0-next.5) (2021-02-04)
148
+
149
+
150
+ ### Features
151
+
152
+ * **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))
153
+
154
+
155
+ ### BREAKING CHANGES
156
+
157
+ `ts-jest` custom AST transformer function signature has changed to
158
+ ```
159
+ import type { TsCompilerInstance } from 'ts-jest/dist/types'
160
+
161
+ export function factory(compilerInstance: TsCompilerInstance) {
162
+ //...
163
+ }
164
+ ```
165
+
166
+
167
+
61
168
  # [26.5.0](https://github.com/kulshekhar/ts-jest/compare/v26.5.0...v26.4.4) (2021-01-29)
62
169
 
63
170
 
@@ -77,6 +184,147 @@
77
184
 
78
185
 
79
186
 
187
+ # [27.0.0-next.4](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.3...v27.0.0-next.4) (2021-01-22)
188
+
189
+
190
+ ### Features
191
+
192
+ * **config:** replace `pathRegex` with `exclude` ([#2295](https://github.com/kulshekhar/ts-jest/issues/2295)) ([f2f99c3](https://github.com/kulshekhar/ts-jest/commit/f2f99c3a46ac18a1fd6cc98922329b71a7e8c4e8))
193
+ * **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))
194
+
195
+
196
+ ### BREAKING CHANGES
197
+
198
+ * One is currently using `pathRegex` should use `exclude` with Glob patterns.
199
+ * If one currently relies on type check for `js` files, please set `checkJs: true` in your tsconfig
200
+
201
+
202
+
203
+ # [27.0.0-next.3](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-next.2...v27.0.0-next.3) (2021-01-14)
204
+
205
+
206
+ ### Bug Fixes
207
+
208
+ * 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))
209
+
210
+
211
+ ### Features
212
+
213
+ * **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)
214
+
215
+
216
+
217
+ # [27.0.0-next.2](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-alpha.1...v27.0.0-next.2) (2020-12-17)
218
+
219
+
220
+ ### Bug Fixes
221
+
222
+ * redo type checking when type has changed in watch mode ([#2167](https://github.com/kulshekhar/ts-jest/issues/2167)) ([ec70365](https://github.com/kulshekhar/ts-jest/commit/ec7036517ac218c2dc9cc20f5127025d21d5ada6)), closes [#2118](https://github.com/kulshekhar/ts-jest/issues/2118) [#1122](https://github.com/kulshekhar/ts-jest/issues/1122) [#943](https://github.com/kulshekhar/ts-jest/issues/943)
223
+
224
+
225
+ ### Features
226
+
227
+ * **compiler:** allow `isolatedModule: true` to have ESM support ([#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)
228
+ * **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))
229
+ * 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))
230
+ * support jest 27 ([#2171](https://github.com/kulshekhar/ts-jest/issues/2171)) ([9909b9d](https://github.com/kulshekhar/ts-jest/commit/9909b9d6b6c72b4c64d2d0ff46f142b2a65a7eae))
231
+
232
+
233
+ ### Performance Improvements
234
+
235
+ * 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))
236
+
237
+
238
+
239
+ # [27.0.0-alpha.1](https://github.com/kulshekhar/ts-jest/compare/v27.0.0-alpha.0...v27.0.0-alpha.1) (2020-11-26)
240
+
241
+
242
+ ### BREAKING CHANGES
243
+
244
+ * By default, when no `target` is defined in `tsconfig`, `ts-jest` will transform codes to ES2015 syntax
245
+ * 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`.
246
+
247
+
248
+
249
+
250
+ # [27.0.0-alpha.0](https://github.com/kulshekhar/ts-jest/compare/v26.4.4...v27.0.0-alpha.0) (2020-11-11)
251
+
252
+
253
+ ### Build System
254
+
255
+ * **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))
256
+
257
+
258
+ ### Code Refactoring
259
+
260
+ * **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))
261
+ * **config:** remove support for `packageJson` option ([#2128](https://github.com/kulshekhar/ts-jest/issues/2128)) ([05916b9](https://github.com/kulshekhar/ts-jest/commit/05916b920160da5b43a20b47025eea43b4a1a5c3))
262
+ * 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))
263
+ * **config:** remove support for `tsConfig` option ([#2127](https://github.com/kulshekhar/ts-jest/issues/2127)) ([3cc9b80](https://github.com/kulshekhar/ts-jest/commit/3cc9b806be2b2096b981253d39ca40df65bb0f7b))
264
+
265
+
266
+ ### BREAKING CHANGES
267
+
268
+ * **config:** `packageJson` config option is not used in internal `ts-jest` so this option is now removed
269
+ * **devs-infra:** `ts-jest` no longer ships with `es5` build but now with `es2015`
270
+ * **config:** One is defining ast transformers in `jest.config.js`/`package.json` should change to
271
+ ```
272
+ // jest.config.js
273
+ module.exports = {
274
+ //...
275
+ globals: {
276
+ 'ts-jest': {
277
+ astTransformers: {
278
+ before: ['your_before_transformer_path'],
279
+ after: ['your_after_transformer_path'],
280
+ afterDeclarations: ['your_afterDeclarations_transformer_path'],
281
+ }
282
+ }
283
+ }
284
+ }
285
+ ```
286
+
287
+ or
288
+ ```
289
+ // package.json
290
+ {
291
+ "jest": {
292
+ "globals": {
293
+ "ts-jest": {
294
+ "astTransformers": {
295
+ "before": ["your_before_transformer_path"],
296
+ "after": ["your_after_transformer_path"],
297
+ "afterDeclarations": ["your_afterDeclarations_transformer_path"]
298
+ }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ ```
304
+ - One currently refers type in `jest.config.js`
305
+ ```
306
+ /** @typedef {import('ts-jest')} */
307
+ module.exports = {
308
+ //...
309
+ }
310
+ ```
311
+
312
+ should change to
313
+ ```
314
+ /** @typedef {import('ts-jest/dist/types')} */
315
+ module.exports = {
316
+ //...
317
+ }
318
+ ```
319
+
320
+ - Remove possibilities to import `mocked`, `createJestPreset`, `pathsToModuleNameMapper` from package entry. One should change to
321
+ ```
322
+ import { mocked, createJestPreset, pathsToModuleNameMapper` } from 'ts-jest/utils'
323
+ ```
324
+ * **config:** One currently uses `tsConfig` should change to `tsconfig` in your `jest.config.js` or `package.json`
325
+
326
+
327
+
80
328
  ## [26.4.4](https://github.com/kulshekhar/ts-jest/compare/v26.4.3...v26.4.4) (2020-11-08)
81
329
 
82
330
 
package/CONTRIBUTING.md CHANGED
@@ -21,19 +21,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
21
21
 
22
22
  Examples of behavior that contributes to creating a positive environment include:
23
23
 
24
- * Using welcoming and inclusive language
25
- * Being respectful of differing viewpoints and experiences
26
- * Gracefully accepting constructive criticism
27
- * Focusing on what is best for the community
28
- * Showing empathy towards other community members
24
+ - Using welcoming and inclusive language
25
+ - Being respectful of differing viewpoints and experiences
26
+ - Gracefully accepting constructive criticism
27
+ - Focusing on what is best for the community
28
+ - Showing empathy towards other community members
29
29
 
30
30
  Examples of unacceptable behavior by participants include:
31
31
 
32
- * The use of sexualized language or imagery and unwelcome sexual attention or advances
33
- * Trolling, insulting/derogatory comments, and personal or political attacks
34
- * Public or private harassment
35
- * Publishing others' private information, such as a physical or electronic address, without explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a professional setting
32
+ - The use of sexualized language or imagery and unwelcome sexual attention or advances
33
+ - Trolling, insulting/derogatory comments, and personal or political attacks
34
+ - Public or private harassment
35
+ - Publishing others' private information, such as a physical or electronic address, without explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
37
37
 
38
38
  ### Our Responsibilities
39
39
 
package/README.md CHANGED
@@ -1,33 +1,33 @@
1
1
  <h1 align="center">ts-jest</h1>
2
2
 
3
- <p align="center">A TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.</p>
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>
7
8
  <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>
8
9
  <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>
9
10
  <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>
10
- <a href="https://travis-ci.com/kulshekhar/ts-jest"><img src="https://travis-ci.com/kulshekhar/ts-jest.svg?branch=master" alt="Build status"/> </a>
11
11
  <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
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>
13
13
  </p>
14
14
 
15
15
  <img src="./icon.png" align="right" title="ts-jest Logo" width="128" height="128">
16
16
 
17
- It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript` **vs** TypeScript (and `ts-jest`)](https://kulshekhar.github.io/ts-jest/user/babel7-or-ts).
17
+ It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript` **vs** TypeScript (and `ts-jest`)](https://kulshekhar.github.io/ts-jest/docs/babel7-or-ts).
18
18
 
19
19
  ---
20
20
 
21
21
  | We are not doing semantic versioning and `23.10` is a re-write, run `npm i -D ts-jest@"<23.10.0"` to go back to the previous version |
22
- |---|
22
+ | ------------------------------------------------------------------------------------------------------------------------------------ |
23
23
 
24
- [<img src="./docs/assets/img/documentation.png" align="left" height="24"> View the online documentation (usage & technical)](https://kulshekhar.github.io/ts-jest)
24
+ [<img src="./website/static/img/documentation.png" align="left" height="24"> View the online documentation (usage & technical)](https://kulshekhar.github.io/ts-jest)
25
25
 
26
- [<img src="./docs/assets/img/slack.png" align="left" height="24"> Ask for some help in the `ts-jest` community of Slack](https://bit.ly/3bRHFPQ)
26
+ [<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
27
 
28
- [<img src="./docs/assets/img/troubleshooting.png" align="left" height="24"> Before reporting any issue, be sure to check the troubleshooting page](TROUBLESHOOTING.md)
28
+ [<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
29
 
30
- [<img src="./docs/assets/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)
30
+ [<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
31
 
32
32
  ---
33
33
 
@@ -35,18 +35,18 @@ It supports all features of TypeScript including type-checking. [Read more about
35
35
 
36
36
  These instructions will get you setup to use `ts-jest` in your project. For more detailed documentation, please check [online documentation](https://kulshekhar.github.io/ts-jest).
37
37
 
38
- | | using npm | using yarn |
39
- |---:|---|---|
40
- | **Prerequisites** | `npm i -D jest typescript` | `yarn add --dev jest typescript` |
41
- | **Installing** | `npm i -D ts-jest @types/jest` | `yarn add --dev ts-jest @types/jest` |
42
- | **Creating config** | `npx ts-jest config:init` | `yarn ts-jest config:init` |
43
- | **Running tests** | `npm t` or `npx jest` | `yarn test` or `yarn jest` |
38
+ | | using npm | using yarn |
39
+ | ------------------: | ------------------------------ | ------------------------------------ |
40
+ | **Prerequisites** | `npm i -D jest typescript` | `yarn add --dev jest typescript` |
41
+ | **Installing** | `npm i -D ts-jest @types/jest` | `yarn add --dev ts-jest @types/jest` |
42
+ | **Creating config** | `npx ts-jest config:init` | `yarn ts-jest config:init` |
43
+ | **Running tests** | `npm t` or `npx jest` | `yarn test` or `yarn jest` |
44
44
 
45
45
  ## Built With
46
46
 
47
- * [TypeScript](https://www.typescriptlang.org/) - JavaScript that scales
48
- * [Jest](https://jestjs.io/) - Delightful JavaScript Testing
49
- * [`ts-jest`](https://kulshekhar.github.io/ts-jest) - Jest processor for TypeScript _(yes, `ts-jest` uses itself for its tests)_
47
+ - [TypeScript](https://www.typescriptlang.org/) - JavaScript that scales
48
+ - [Jest](https://jestjs.io/) - Delightful JavaScript Testing
49
+ - [`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
50
 
51
51
  ## Contributing
52
52
 
@@ -58,10 +58,10 @@ We **DO NOT** use [SemVer](http://semver.org/) for versioning. Though you can th
58
58
 
59
59
  ## Authors/maintainers
60
60
 
61
- * **Kulshekhar Kabra** - [kulshekhar](https://github.com/kulshekhar)
62
- * **Gustav Wengel** - [GeeWee](https://github.com/GeeWee)
63
- * **Ahn** - [ahnpnl](https://github.com/ahnpnl)
64
- * **Huafu Gandon** - [huafu](https://github.com/huafu)
61
+ - **Kulshekhar Kabra** - [kulshekhar](https://github.com/kulshekhar)
62
+ - **Gustav Wengel** - [GeeWee](https://github.com/GeeWee)
63
+ - **Ahn** - [ahnpnl](https://github.com/ahnpnl)
64
+ - **Huafu Gandon** - [huafu](https://github.com/huafu)
65
65
 
66
66
  See also the list of [contributors](https://github.com/kulshekhar/ts-jest/contributors) who participated in this project.
67
67
 
package/cli.js CHANGED
File without changes
@@ -49,10 +49,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.help = exports.run = void 0;
51
51
  var fs_1 = require("fs");
52
- var json5_1 = require("json5");
53
52
  var path_1 = require("path");
53
+ var json5_1 = require("json5");
54
54
  var presets_1 = require("../helpers/presets");
55
- exports.run = function (args) { return __awaiter(void 0, void 0, void 0, function () {
55
+ var run = function (args) { return __awaiter(void 0, void 0, void 0, function () {
56
56
  var file, filePath, name, isPackage, exists, pkgFile, hasPackage, _a, jestPreset, askedTsconfig, force, jsdom, tsconfig, pkgJson, jsFilesProcessor, shouldPostProcessWithBabel, preset, body, base, tsJestConf, content;
57
57
  var _b, _c;
58
58
  return __generator(this, function (_d) {
@@ -146,9 +146,11 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
146
146
  return [2];
147
147
  });
148
148
  }); };
149
- exports.help = function () { return __awaiter(void 0, void 0, void 0, function () {
149
+ exports.run = run;
150
+ var help = function () { return __awaiter(void 0, void 0, void 0, function () {
150
151
  return __generator(this, function (_a) {
151
152
  process.stdout.write("\nUsage:\n ts-jest config:init [options] [<config-file>]\n\nArguments:\n <config-file> Can be a js or json Jest config file. If it is a\n package.json file, the configuration will be read from\n the \"jest\" property.\n Default: jest.config.js\n\nOptions:\n --force Discard any existing Jest config\n --js ts|babel Process .js files with ts-jest if 'ts' or with\n babel-jest if 'babel'\n --no-jest-preset Disable the use of Jest presets\n --tsconfig <file> Path to the tsconfig.json file\n --babel Pipe babel-jest after ts-jest\n --jsdom Use jsdom as test environment instead of node\n");
152
153
  return [2];
153
154
  });
154
155
  }); };
156
+ exports.help = help;
@@ -51,20 +51,24 @@ var __read = (this && this.__read) || function (o, n) {
51
51
  }
52
52
  return ar;
53
53
  };
54
- var __spread = (this && this.__spread) || function () {
55
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
56
- return ar;
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
55
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
56
+ to[j] = from[i];
57
+ return to;
58
+ };
59
+ var __importDefault = (this && this.__importDefault) || function (mod) {
60
+ return (mod && mod.__esModule) ? mod : { "default": mod };
57
61
  };
58
62
  Object.defineProperty(exports, "__esModule", { value: true });
59
63
  exports.help = exports.run = void 0;
60
- var bs_logger_1 = require("bs-logger");
61
- var stableStringify = require("fast-json-stable-stringify");
62
64
  var fs_1 = require("fs");
63
- var json5_1 = require("json5");
64
65
  var path_1 = require("path");
66
+ var bs_logger_1 = require("bs-logger");
67
+ var fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
68
+ var json5_1 = require("json5");
65
69
  var backports_1 = require("../../utils/backports");
66
70
  var presets_1 = require("../helpers/presets");
67
- exports.run = function (args) { return __awaiter(void 0, void 0, void 0, function () {
71
+ var run = function (args) { return __awaiter(void 0, void 0, void 0, function () {
68
72
  var nullLogger, file, filePath, footNotes, name, isPackage, actualConfig, migratedConfig, presetName, preset, jsTransformers, jsWithTs, jsWithBabel, presetValue, migratedValue, presetValue, migratedValue, before, after, stringify, prefix;
69
73
  var _a;
70
74
  return __generator(this, function (_b) {
@@ -99,7 +103,7 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
99
103
  transformer = 'babel-jest';
100
104
  else if (/\ts-jest\b/.test(transformer))
101
105
  transformer = 'ts-jest';
102
- return __spread(list, [transformer]);
106
+ return __spreadArray(__spreadArray([], __read(list)), [transformer]);
103
107
  }
104
108
  return list;
105
109
  }, []);
@@ -157,13 +161,13 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
157
161
  }
158
162
  if (preset &&
159
163
  migratedConfig.transform &&
160
- stableStringify(migratedConfig.transform) === stableStringify(preset.value.transform)) {
164
+ fast_json_stable_stringify_1.default(migratedConfig.transform) === fast_json_stable_stringify_1.default(preset.value.transform)) {
161
165
  delete migratedConfig.transform;
162
166
  }
163
167
  cleanupConfig(actualConfig);
164
168
  cleanupConfig(migratedConfig);
165
- before = stableStringify(actualConfig);
166
- after = stableStringify(migratedConfig);
169
+ before = fast_json_stable_stringify_1.default(actualConfig);
170
+ after = fast_json_stable_stringify_1.default(migratedConfig);
167
171
  if (after === before) {
168
172
  process.stderr.write("\nNo migration needed for given Jest configuration\n ");
169
173
  return [2];
@@ -181,6 +185,7 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
181
185
  return [2];
182
186
  });
183
187
  }); };
188
+ exports.run = run;
184
189
  function cleanupConfig(config) {
185
190
  if (config.globals) {
186
191
  if (config.globals['ts-jest'] && Object.keys(config.globals['ts-jest']).length === 0) {
@@ -211,9 +216,10 @@ function dedupSort(arr) {
211
216
  .filter(function (s, i, a) { return a.findIndex(function (e) { return s.toString() === e.toString(); }) === i; })
212
217
  .sort(function (a, b) { return (a.toString() > b.toString() ? 1 : a.toString() < b.toString() ? -1 : 0); });
213
218
  }
214
- exports.help = function () { return __awaiter(void 0, void 0, void 0, function () {
219
+ var help = function () { return __awaiter(void 0, void 0, void 0, function () {
215
220
  return __generator(this, function (_a) {
216
221
  process.stdout.write("\nUsage:\n ts-jest config:migrate [options] <config-file>\n\nArguments:\n <config-file> Can be a js or json Jest config file. If it is a\n package.json file, the configuration will be read from\n the \"jest\" property.\n\nOptions:\n --js ts|babel Process .js files with ts-jest if 'ts' or with\n babel-jest if 'babel'\n --no-jest-preset Disable the use of Jest presets\n");
217
222
  return [2];
218
223
  });
219
224
  }); };
225
+ exports.help = help;
package/dist/cli/help.js CHANGED
@@ -37,10 +37,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.help = exports.run = void 0;
40
- exports.run = function (_) { return __awaiter(void 0, void 0, void 0, function () {
40
+ var run = function (_) { return __awaiter(void 0, void 0, void 0, function () {
41
41
  return __generator(this, function (_a) {
42
42
  process.stdout.write("\nUsage:\n ts-jest command [options] [...args]\n\nCommands:\n config:init Creates initial Jest configuration\n config:migrate Migrates a given Jest configuration\n help [command] Show this help, or help about a command\n\nExample:\n ts-jest help config:migrate\n");
43
43
  return [2];
44
44
  });
45
45
  }); };
46
+ exports.run = run;
46
47
  exports.help = exports.run;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateOutput = exports.SOURCE_MAPPING_PREFIX = void 0;
4
+ var json_1 = require("../utils/json");
5
+ exports.SOURCE_MAPPING_PREFIX = 'sourceMappingURL=';
6
+ function updateOutput(outputText, normalizedFileName, sourceMap) {
7
+ var base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
8
+ var sourceMapContent = "data:application/json;charset=utf-8;base64," + base64Map;
9
+ return (outputText.slice(0, outputText.lastIndexOf(exports.SOURCE_MAPPING_PREFIX) + exports.SOURCE_MAPPING_PREFIX.length) + sourceMapContent);
10
+ }
11
+ exports.updateOutput = updateOutput;
12
+ var updateSourceMap = function (sourceMapText, normalizedFileName) {
13
+ var sourceMap = JSON.parse(sourceMapText);
14
+ sourceMap.file = normalizedFileName;
15
+ sourceMap.sources = [normalizedFileName];
16
+ delete sourceMap.sourceRoot;
17
+ return json_1.stringify(sourceMap);
18
+ };
@@ -0,0 +1,20 @@
1
+ import { Logger } from 'bs-logger';
2
+ import type { TranspileOutput, CompilerOptions, Program, CustomTransformers } from 'typescript';
3
+ import type { ConfigSet } from '../config/config-set';
4
+ import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript } from '../types';
5
+ export declare class TsCompiler implements TsCompilerInstance {
6
+ readonly configSet: ConfigSet;
7
+ readonly runtimeCacheFS: StringMap;
8
+ protected readonly _logger: Logger;
9
+ protected readonly _ts: TTypeScript;
10
+ protected readonly _initialCompilerOptions: CompilerOptions;
11
+ protected _compilerOptions: CompilerOptions;
12
+ private _runtimeCacheFS;
13
+ private _fileContentCache;
14
+ program: Program | undefined;
15
+ constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
16
+ getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
17
+ getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): string;
18
+ protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput;
19
+ protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers;
20
+ }