aboutsummaryrefslogtreecommitdiffstats
path: root/config/jestEsbuildTransform.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/jestEsbuildTransform.js')
-rw-r--r--config/jestEsbuildTransform.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/config/jestEsbuildTransform.js b/config/jestEsbuildTransform.js
new file mode 100644
index 0000000..7c6a57c
--- /dev/null
+++ b/config/jestEsbuildTransform.js
@@ -0,0 +1,26 @@
1import { transform } from 'esbuild';
2
3import { node } from './buildConstants.js';
4
5export default {
6 /**
7 * @param {string} source
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) {
13 const { code } = await transform(source, {
14 loader: filePath.endsWith('tsx') ? 'tsx' : 'ts',
15 sourcefile: filePath,
16 format: 'esm',
17 target: node,
18 sourcemap: 'inline',
19 });
20 return {
21 code,
22 originalCode: source,
23 sourceMapPath: null,
24 };
25 },
26};