-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranspile-at-runtime.js
37 lines (31 loc) · 1 KB
/
transpile-at-runtime.js
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
29
30
31
32
33
34
35
36
37
/* eslint-disable @typescript-eslint/no-var-requires */
const { relative } = require('path');
const register = require('@babel/register');
const { matcher } = require('micromatch');
const config = require('@monorepo/config');
const transpilationGlobs = [...config.buildableSourceCodeGlobs, ...config.testCodeGlobs];
const transpilationIgnoreGlobs = config.buildableIgnoreGlobs;
const isMatch = matcher(transpilationGlobs, {
ignore: transpilationIgnoreGlobs,
});
register({
extensions: config.codeExtensions.map((extension) => `.${extension}`),
only: [
(testPath) => {
const relativePath = relative(__dirname, testPath);
switch (relativePath) {
case 'webpack.config.ts':
case 'original-code-require-override.ts':
case 'buildplan.ts':
case 'build-import-map.ts':
return true;
default: {
if (relativePath.startsWith('buildplan')) {
return true;
}
return isMatch(relativePath);
}
}
},
],
});