blob: b6f2fc35c40e3a99e6a52cf3dd389f3d4ccacf89 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { transform } from 'esbuild';
import { node } from './buildConstants.js';
/**
* @param {string} source
* @param {import('@jest/types').Config.Path} filePath
* @return {Promise<import('@jest/transform').TransformedSource>}
*/
async function processAsync(source, filePath) {
const { code, map } = await transform(source, {
loader: filePath.endsWith('tsx') ? 'tsx' : 'ts',
sourcefile: filePath,
format: 'esm',
target: node,
sourcemap: true,
});
return {
code,
map,
};
}
/** @type {import('@jest/transform').AsyncTransformer<void>} */
export default {
canInstrument: false,
processAsync,
};
|