diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/buildConstants.js | 4 | ||||
-rw-r--r-- | config/fileURLToDirname.js (renamed from config/utils.js) | 2 | ||||
-rw-r--r-- | config/getEsbuildConfig.js (renamed from config/esbuildConfig.js) | 2 | ||||
-rw-r--r-- | config/jest.config.base.js | 4 | ||||
-rw-r--r-- | config/jestEsbuildTransform.js | 23 | ||||
-rw-r--r-- | config/jestEsbuildTransformer.js | 28 | ||||
-rw-r--r-- | config/tsconfig.base.json | 19 |
7 files changed, 54 insertions, 28 deletions
diff --git a/config/buildConstants.js b/config/buildConstants.js index 627c895..9083d78 100644 --- a/config/buildConstants.js +++ b/config/buildConstants.js | |||
@@ -1,7 +1,7 @@ | |||
1 | import { readFileSync } from 'fs'; | 1 | import { readFileSync } from 'fs'; |
2 | import { join } from 'path'; | 2 | import { join } from 'path'; |
3 | 3 | ||
4 | import { fileURLToDirname } from './utils.js'; | 4 | import fileURLToDirname from './fileURLToDirname.js'; |
5 | 5 | ||
6 | const thisDir = fileURLToDirname(import.meta.url); | 6 | const thisDir = fileURLToDirname(import.meta.url); |
7 | 7 | ||
@@ -9,6 +9,8 @@ const thisDir = fileURLToDirname(import.meta.url); | |||
9 | // so we have to use the synchronous filesystem API. | 9 | // so we have to use the synchronous filesystem API. |
10 | const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8'); | 10 | const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8'); |
11 | 11 | ||
12 | /** @type {{ chrome: number; node: number; }} */ | ||
13 | // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
12 | const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson); | 14 | const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson); |
13 | 15 | ||
14 | /** @type {string} */ | 16 | /** @type {string} */ |
diff --git a/config/utils.js b/config/fileURLToDirname.js index d3e13d9..70654cb 100644 --- a/config/utils.js +++ b/config/fileURLToDirname.js | |||
@@ -5,6 +5,6 @@ import { fileURLToPath } from 'url'; | |||
5 | * @param {string} url | 5 | * @param {string} url |
6 | * @returns {string} | 6 | * @returns {string} |
7 | */ | 7 | */ |
8 | export function fileURLToDirname(url) { | 8 | export default function fileURLToDirname(url) { |
9 | return dirname(fileURLToPath(url)); | 9 | return dirname(fileURLToPath(url)); |
10 | } | 10 | } |
diff --git a/config/esbuildConfig.js b/config/getEsbuildConfig.js index 93419fb..b338d68 100644 --- a/config/esbuildConfig.js +++ b/config/getEsbuildConfig.js | |||
@@ -15,7 +15,7 @@ const modeString = JSON.stringify(mode); | |||
15 | * @param {Record<string, unknown>} [extraMetaEnvVars] | 15 | * @param {Record<string, unknown>} [extraMetaEnvVars] |
16 | * @returns {import('esbuild').BuildOptions} | 16 | * @returns {import('esbuild').BuildOptions} |
17 | */ | 17 | */ |
18 | export function getConfig(config, extraMetaEnvVars) { | 18 | export default function getEsbuildConfig(config, extraMetaEnvVars) { |
19 | return { | 19 | return { |
20 | logLevel: 'info', | 20 | logLevel: 'info', |
21 | bundle: true, | 21 | bundle: true, |
diff --git a/config/jest.config.base.js b/config/jest.config.base.js index 2ca021b..463e498 100644 --- a/config/jest.config.base.js +++ b/config/jest.config.base.js | |||
@@ -1,13 +1,13 @@ | |||
1 | import { join } from 'path'; | 1 | import { join } from 'path'; |
2 | 2 | ||
3 | import { fileURLToDirname } from './utils.js'; | 3 | import fileURLToDirname from './fileURLToDirname.js'; |
4 | 4 | ||
5 | const thisDir = fileURLToDirname(import.meta.url); | 5 | const thisDir = fileURLToDirname(import.meta.url); |
6 | 6 | ||
7 | /** @type {import('@jest/types').Config.InitialOptions} */ | 7 | /** @type {import('@jest/types').Config.InitialOptions} */ |
8 | export default { | 8 | export default { |
9 | transform: { | 9 | transform: { |
10 | '\\.tsx?$': join(thisDir, 'jestEsbuildTransform.js'), | 10 | '\\.tsx?$': join(thisDir, 'jestEsbuildTransformer.js'), |
11 | }, | 11 | }, |
12 | extensionsToTreatAsEsm: [ | 12 | extensionsToTreatAsEsm: [ |
13 | '.ts', | 13 | '.ts', |
diff --git a/config/jestEsbuildTransform.js b/config/jestEsbuildTransform.js deleted file mode 100644 index 4bf49e6..0000000 --- a/config/jestEsbuildTransform.js +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | import { transform } from 'esbuild'; | ||
2 | |||
3 | import { node } from './buildConstants.js'; | ||
4 | |||
5 | /** @type {import('@jest/transform').AsyncTransformer<undefined>} */ | ||
6 | const transformer = { | ||
7 | canInstrument: false, | ||
8 | async processAsync(source, filePath) { | ||
9 | const { code, map } = await transform(source, { | ||
10 | loader: filePath.endsWith('tsx') ? 'tsx' : 'ts', | ||
11 | sourcefile: filePath, | ||
12 | format: 'esm', | ||
13 | target: node, | ||
14 | sourcemap: true, | ||
15 | }); | ||
16 | return { | ||
17 | code, | ||
18 | map, | ||
19 | }; | ||
20 | }, | ||
21 | }; | ||
22 | |||
23 | export default transformer; | ||
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 | }; | ||
diff --git a/config/tsconfig.base.json b/config/tsconfig.base.json new file mode 100644 index 0000000..255f334 --- /dev/null +++ b/config/tsconfig.base.json | |||
@@ -0,0 +1,19 @@ | |||
1 | { | ||
2 | "compilerOptions": { | ||
3 | "module": "esnext", | ||
4 | "target": "esnext", | ||
5 | "moduleResolution": "node", | ||
6 | "esModuleInterop": true, | ||
7 | "allowSyntheticDefaultImports": true, | ||
8 | "strict": true, | ||
9 | "noImplicitOverride": true, | ||
10 | "noImplicitReturns": true, | ||
11 | "exactOptionalPropertyTypes": true, | ||
12 | "isolatedModules": true, | ||
13 | "skipLibCheck": true, | ||
14 | "checkJs": true, | ||
15 | "lib": [ | ||
16 | "esnext" | ||
17 | ] | ||
18 | } | ||
19 | } | ||