diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-01-08 21:36:43 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-01-09 19:53:03 +0100 |
commit | d07e7b834831230b53860d0919a68edc2d36193d (patch) | |
tree | a1f2a021563ddff54f33341c475fc6c6eb787388 /config/jestEsbuildTransformer.js | |
parent | New configurations based on review comments (WIP) (diff) | |
download | sophie-d07e7b834831230b53860d0919a68edc2d36193d.tar.gz sophie-d07e7b834831230b53860d0919a68edc2d36193d.tar.zst sophie-d07e7b834831230b53860d0919a68edc2d36193d.zip |
build: Eslint fixes for multi-module project
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'config/jestEsbuildTransformer.js')
-rw-r--r-- | config/jestEsbuildTransformer.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/config/jestEsbuildTransformer.js b/config/jestEsbuildTransformer.js new file mode 100644 index 0000000..b6f2fc3 --- /dev/null +++ b/config/jestEsbuildTransformer.js | |||
@@ -0,0 +1,28 @@ | |||
1 | import { transform } from 'esbuild'; | ||
2 | |||
3 | import { node } from './buildConstants.js'; | ||
4 | |||
5 | /** | ||
6 | * @param {string} source | ||
7 | * @param {import('@jest/types').Config.Path} filePath | ||
8 | * @return {Promise<import('@jest/transform').TransformedSource>} | ||
9 | */ | ||
10 | async function processAsync(source, filePath) { | ||
11 | const { code, map } = await transform(source, { | ||
12 | loader: filePath.endsWith('tsx') ? 'tsx' : 'ts', | ||
13 | sourcefile: filePath, | ||
14 | format: 'esm', | ||
15 | target: node, | ||
16 | sourcemap: true, | ||
17 | }); | ||
18 | return { | ||
19 | code, | ||
20 | map, | ||
21 | }; | ||
22 | } | ||
23 | |||
24 | /** @type {import('@jest/transform').AsyncTransformer<void>} */ | ||
25 | export default { | ||
26 | canInstrument: false, | ||
27 | processAsync, | ||
28 | }; | ||