fix frontend build

This commit is contained in:
Hazelnoot 2025-10-07 19:55:08 -04:00
parent 19193b66aa
commit d06c07b97b
6 changed files with 54 additions and 16 deletions

View file

@ -1 +1,2 @@
/storybook-static
tsconfig.json.bak

View file

@ -170,6 +170,7 @@ export default [
autofix: true,
}],
'vue/attribute-hyphenation': ['error', 'never'],
'import/no-default-export': 'off',
},
},
{

View file

@ -3,19 +3,21 @@
"private": true,
"type": "module",
"scripts": {
"watch": "vite",
"build": "vite build",
"watch": "node scripts/build.mjs --watch",
"build": "node scripts/build.mjs",
"build:pre": "pnpm run --filter misskey-js build && pnpm run --filter misskey-reversi build && pnpm run --filter misskey-bubble-game build && pnpm run --filter sw build && pnpm run --filter frontend_shared build",
"storybook-dev": "nodemon --verbose --watch src --ext \"mdx,ts,vue\" --ignore \"*.stories.ts\" --exec \"pnpm build-storybook-pre && pnpm exec storybook dev -p 6006 --ci\"",
"build-storybook-pre": "(tsc -p .storybook || echo done.) && node .storybook/generate.js && node .storybook/preload-locale.js && node .storybook/preload-theme.js",
"build-storybook": "pnpm build-storybook-pre && storybook build --webpack-stats-json storybook-static",
"chromatic": "chromatic",
"test": "vitest --run --globals",
"test-and-coverage": "vitest --run --coverage --globals",
"typecheck-all": "pnpm run --no-bail typecheck:vue && pnpm run --no-bail typecheck:test && pnpm run --no-bail typecheck:scripts",
"typecheck": "pnpm run typecheck:vue && pnpm run typecheck:test && pnpm run typecheck:scripts",
"typecheck-all": "pnpm run --no-bail typecheck:vue && pnpm run --no-bail typecheck:test && pnpm run --no-bail typecheck:scripts && pnpm run --no-bail typecheck:storybook",
"typecheck": "pnpm run typecheck:vue && pnpm run typecheck:test && pnpm run typecheck:scripts && pnpm run typecheck:storybook",
"typecheck:vue": "vue-tsc -p tsconfig.vue.json --noEmit",
"typecheck:test": "vue-tsc -p test/tsconfig.json --noEmit",
"typecheck:scripts": "tsc -p tsconfig.scripts.json --noEmit",
"typecheck:storybook": "tsc -p tsconfig.storybook.json --noEmit",
"eslint": "eslint --quiet --cache -c eslint.config.js .",
"lint": "pnpm typecheck && pnpm eslint"
},
@ -120,6 +122,7 @@
"eslint-plugin-import": "2.32.0",
"eslint-plugin-vue": "10.5.0",
"estree-walker": "3.0.3",
"execa": "9.6.0",
"fast-glob": "3.3.3",
"happy-dom": "18.0.1",
"intersection-observer": "0.12.2",

View file

@ -0,0 +1,37 @@
/**
* Hot-swaps tsconfig files to work around vite limitations.
* Based on idea from https://github.com/vitejs/vite/discussions/8483#discussioncomment-6830634
*/
import nodeFs from 'node:fs/promises';
import nodePath from 'node:path';
import { execa } from 'execa';
const rootDir = nodePath.resolve(import.meta.dirname, '../');
const tsConfig = nodePath.resolve(rootDir, 'tsconfig.json');
const tsConfigBak = nodePath.resolve(rootDir, 'tsconfig.json.bak');
const tsConfigVue = nodePath.resolve(rootDir, 'tsconfig.vue.json');
const mode = process.argv.slice(2).includes('--watch') ? 'watch' : 'build';
console.log('Staging tsconfig.vue.json as tsconfig.json...');
await nodeFs.rename(tsConfig, tsConfigBak);
await nodeFs.copyFile(tsConfigVue, tsConfig);
try {
console.log('Starting vite...')
await execa(
'vite',
mode === 'build'
? ['build']
: [],
{
stdout: process.stdout,
stderr: process.stderr,
},
);
} finally {
console.log('Restoring original tsconfig.json...');
await nodeFs.rm(tsConfig);
await nodeFs.rename(tsConfigBak, tsConfig);
}

View file

@ -2,6 +2,12 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../shared/tsconfig.web.jsonc",
"compilerOptions": {
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"experimentalDecorators": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"paths": {
"@/*": ["./src/*"],
"@@/*": ["../frontend-shared/*"]
@ -24,12 +30,10 @@
"./src/**/*.vue",
"./test/**/*.ts",
"./test/**/*.vue",
"./@types/**/*.ts",
"./vue-shims.d.ts"
"./@types/**/*.ts"
],
"exclude": [
"node_modules",
".storybook/**/*",
"*.*"
".storybook/**/*"
]
}

View file

@ -7,11 +7,9 @@ import locales from '../../locales/index.js';
import { localesVersion } from '../../locales/version.js';
import meta from '../../package.json' with { type: 'json' };
import packageInfo from './package.json' with { type: 'json' };
import tsconfigVue from './tsconfig.vue.json' with { type: 'json' };
import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name.js';
import pluginJson5 from './vite.json5.js';
import pluginCreateSearchIndex from './lib/vite-plugin-create-search-index.js';
import type { TsconfigRaw } from 'esbuild';
import type { UserConfig } from 'vite';
import type { Options as SearchIndexOptions } from './lib/vite-plugin-create-search-index.js';
@ -168,12 +166,6 @@ export function getConfig(): UserConfig {
_RUFFLE_VERSION_: JSON.stringify(packageInfo.dependencies['@ruffle-rs/ruffle']),
},
esbuild: {
// https://github.com/vitejs/vite/discussions/8483#discussioncomment-14485974
// https://esbuild.github.io/api/#tsconfig-raw
tsconfigRaw: tsconfigVue as TsconfigRaw,
},
build: {
target: [
'chrome116',