aboutsummaryrefslogtreecommitdiffstats
path: root/config/build-common.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/build-common.js')
-rw-r--r--config/build-common.js28
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 1import { readFileSync } from 'fs';
2import { dirname, join } from 'path';
3import { fileURLToPath } from 'url';
2 4
3// `resolveJsonModule` is disabled for this package, but vite will load the json nevertheless. 5const thisDir = fileURLToDirname(import.meta.url);
4// @ts-ignore 6
5const { 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.
9const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8');
10
11const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson);
6 12
7/** @type {string} */ 13/** @type {string} */
8module.exports.banner = `/*! 14export 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} */
30module.exports.chrome = `chrome${chromeVersion}`; 36export const chrome = `chrome${chromeVersion}`;
31 37
32/** @type {string} */ 38/** @type {string} */
33module.exports.node = `node${nodeVersion}`; 39export const node = `node${nodeVersion}`;
40
41/**
42 * @param {string} url
43 * @returns {string}
44 */
45export function fileURLToDirname(url) {
46 return dirname(fileURLToPath(url));
47}