diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-12-31 18:19:06 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-12-31 18:20:22 +0100 |
commit | f926feec81970a401cd7c7d1a088aa8201e2e57d (patch) | |
tree | 958cd5593fb39bf074a9d915e6b3ccea1dd0793f | |
parent | test: More robust jest moduleNameMappers (diff) | |
download | sophie-f926feec81970a401cd7c7d1a088aa8201e2e57d.tar.gz sophie-f926feec81970a401cd7c7d1a088aa8201e2e57d.tar.zst sophie-f926feec81970a401cd7c7d1a088aa8201e2e57d.zip |
test: Fix esbuild transformer types
-rw-r--r-- | config/jestEsbuildTransform.js | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/config/jestEsbuildTransform.js b/config/jestEsbuildTransform.js index 7c6a57c..4bf49e6 100644 --- a/config/jestEsbuildTransform.js +++ b/config/jestEsbuildTransform.js | |||
@@ -2,25 +2,22 @@ import { transform } from 'esbuild'; | |||
2 | 2 | ||
3 | import { node } from './buildConstants.js'; | 3 | import { node } from './buildConstants.js'; |
4 | 4 | ||
5 | export default { | 5 | /** @type {import('@jest/transform').AsyncTransformer<undefined>} */ |
6 | /** | 6 | const transformer = { |
7 | * @param {string} source | 7 | canInstrument: false, |
8 | * @param {string} filePath | ||
9 | * @param {import('@jest/types').Config.GlobalConfig} jestConfig | ||
10 | * @return {Promise<import('@jest/types').TransformTypes.TransformResult>} | ||
11 | */ | ||
12 | async processAsync(source, filePath) { | 8 | async processAsync(source, filePath) { |
13 | const { code } = await transform(source, { | 9 | const { code, map } = await transform(source, { |
14 | loader: filePath.endsWith('tsx') ? 'tsx' : 'ts', | 10 | loader: filePath.endsWith('tsx') ? 'tsx' : 'ts', |
15 | sourcefile: filePath, | 11 | sourcefile: filePath, |
16 | format: 'esm', | 12 | format: 'esm', |
17 | target: node, | 13 | target: node, |
18 | sourcemap: 'inline', | 14 | sourcemap: true, |
19 | }); | 15 | }); |
20 | return { | 16 | return { |
21 | code, | 17 | code, |
22 | originalCode: source, | 18 | map, |
23 | sourceMapPath: null, | ||
24 | }; | 19 | }; |
25 | }, | 20 | }, |
26 | }; | 21 | }; |
22 | |||
23 | export default transformer; | ||