fix sw build

This commit is contained in:
Kagami Sascha Rosylight 2023-07-09 00:53:59 +02:00
parent 5bd0228da2
commit 7e9b3441eb
3 changed files with 9 additions and 5 deletions

View File

@ -51,7 +51,7 @@ const primaries = {
// 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く // 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く
const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), ''); const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(`${__dirname}/${c}.yml`, 'utf-8'))) || {}, a), {}); const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, import.meta.url), 'utf-8'))) || {}, a), {});
export default Object.entries(locales) export default Object.entries(locales)
.reduce((a, [k ,v]) => (a[k] = (() => { .reduce((a, [k ,v]) => (a[k] = (() => {

View File

@ -1,10 +1,13 @@
// @ts-check // @ts-check
const esbuild = require('esbuild'); import * as esbuild from 'esbuild';
const locales = require('../../locales'); import locales from '../../locales/index.js';
const meta = require('../../package.json'); import meta from '../../package.json' assert { type: "json" };
import { fileURLToPath } from 'node:url';
const watch = process.argv[2]?.includes('watch'); const watch = process.argv[2]?.includes('watch');
const __dirname = fileURLToPath(new URL(".", import.meta.url))
console.log('Starting SW building...'); console.log('Starting SW building...');
/** @type {esbuild.BuildOptions} */ /** @type {esbuild.BuildOptions} */

View File

@ -19,5 +19,6 @@
"eslint": "8.44.0", "eslint": "8.44.0",
"eslint-plugin-import": "2.27.5", "eslint-plugin-import": "2.27.5",
"typescript": "5.1.6" "typescript": "5.1.6"
} },
"type": "module"
} }