diff options
Diffstat (limited to 'config/build-common.js')
-rw-r--r-- | config/build-common.js | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/config/build-common.js b/config/build-common.js index aea2335..ff5a218 100644 --- a/config/build-common.js +++ b/config/build-common.js | |||
@@ -1,11 +1,17 @@ | |||
1 | // @ts-check | 1 | import { readFileSync } from 'fs'; |
2 | import { dirname, join } from 'path'; | ||
3 | import { fileURLToPath } from 'url'; | ||
2 | 4 | ||
3 | // `resolveJsonModule` is disabled for this package, but vite will load the json nevertheless. | 5 | const thisDir = fileURLToDirname(import.meta.url); |
4 | // @ts-ignore | 6 | |
5 | const { chrome: chromeVersion, node: nodeVersion } = require('../.electron-vendors.cache.json'); | 7 | // We import this from a vite config, where top-level await is not available (es2021), |
8 | // so we have to use the synchronous filesystem API. | ||
9 | const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8'); | ||
10 | |||
11 | const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson); | ||
6 | 12 | ||
7 | /** @type {string} */ | 13 | /** @type {string} */ |
8 | module.exports.banner = `/*! | 14 | export const banner = `/*! |
9 | * Copyright (C) 2021-2022 Sophie contributors | 15 | * Copyright (C) 2021-2022 Sophie contributors |
10 | * | 16 | * |
11 | * This file is part of Sophie. | 17 | * This file is part of Sophie. |
@@ -27,7 +33,15 @@ module.exports.banner = `/*! | |||
27 | `; | 33 | `; |
28 | 34 | ||
29 | /** @type {string} */ | 35 | /** @type {string} */ |
30 | module.exports.chrome = `chrome${chromeVersion}`; | 36 | export const chrome = `chrome${chromeVersion}`; |
31 | 37 | ||
32 | /** @type {string} */ | 38 | /** @type {string} */ |
33 | module.exports.node = `node${nodeVersion}`; | 39 | export const node = `node${nodeVersion}`; |
40 | |||
41 | /** | ||
42 | * @param {string} url | ||
43 | * @returns {string} | ||
44 | */ | ||
45 | export function fileURLToDirname(url) { | ||
46 | return dirname(fileURLToPath(url)); | ||
47 | } | ||