aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-31 18:19:06 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-31 18:20:22 +0100
commitf926feec81970a401cd7c7d1a088aa8201e2e57d (patch)
tree958cd5593fb39bf074a9d915e6b3ccea1dd0793f
parenttest: More robust jest moduleNameMappers (diff)
downloadsophie-f926feec81970a401cd7c7d1a088aa8201e2e57d.tar.gz
sophie-f926feec81970a401cd7c7d1a088aa8201e2e57d.tar.zst
sophie-f926feec81970a401cd7c7d1a088aa8201e2e57d.zip
test: Fix esbuild transformer types
-rw-r--r--config/jestEsbuildTransform.js19
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
3import { node } from './buildConstants.js'; 3import { node } from './buildConstants.js';
4 4
5export default { 5/** @type {import('@jest/transform').AsyncTransformer<undefined>} */
6 /** 6const 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
23export default transformer;