Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8644b81
deps: Update vite to v8
kakkokari-gtyih Mar 12, 2026
7d90263
Merge branch 'develop' into experimental-vite8
kakkokari-gtyih Mar 18, 2026
7f34fd1
fix
kakkokari-gtyih Mar 18, 2026
939aac4
migrate some plugins to rolldown-based
kakkokari-gtyih Mar 18, 2026
082967f
fix broken lockfile
kakkokari-gtyih Mar 18, 2026
3a88efb
wip
kakkokari-gtyih Mar 18, 2026
0724328
update rolldown
kakkokari-gtyih Mar 19, 2026
912603d
override rolldown version
kakkokari-gtyih Mar 19, 2026
7c285ea
perf
kakkokari-gtyih Mar 19, 2026
ebc226f
spdx
kakkokari-gtyih Mar 19, 2026
d08307e
fix
kakkokari-gtyih Mar 19, 2026
208f58d
update vite to 8.0.1
kakkokari-gtyih Mar 19, 2026
8c187c2
chore: rewrite rollup-plugin-unwind-css-module-class-name with MagicS…
cm-ayf Mar 19, 2026
a4b1823
fix: lint fixes
kakkokari-gtyih Mar 19, 2026
fca3c2e
swap sass with sass-embedded
kakkokari-gtyih Mar 19, 2026
b6e70d9
fix lint
kakkokari-gtyih Mar 19, 2026
2a71335
fix: インライン化されたVue SFC出力に対してCSS Module定義削除が効かないのを修正
kakkokari-gtyih Mar 19, 2026
6d83f33
fix
kakkokari-gtyih Mar 19, 2026
7e781cf
fix: バックエンドのCSS読み込みの方法が悪いのを修正
kakkokari-gtyih Mar 19, 2026
294d66f
fix: 使用されないpreloadを削除
kakkokari-gtyih Mar 19, 2026
1841640
fix lint [ci skip]
kakkokari-gtyih Mar 19, 2026
ce10283
Apply suggestion from @syuilo
syuilo Mar 20, 2026
b55d7b5
Add comment in pnpm-workspace.yaml [ci skip]
kakkokari-gtyih Mar 20, 2026
b69be04
Merge remote-tracking branch 'msky/develop' into experimental-vite8
kakkokari-gtyih Apr 1, 2026
257dc73
update vite/rolldown
kakkokari-gtyih Apr 1, 2026
10884cf
remove magic-string
kakkokari-gtyih Apr 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,6 @@
"pid-port": "2.1.0",
"simple-oauth2": "5.1.0",
"supertest": "7.2.2",
"vite": "7.3.1"
"vite": "8.0.2"
}
}
22 changes: 13 additions & 9 deletions packages/frontend-builder/locale-inliner/collect-modifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import { parseAst } from 'vite';
import { parseAst } from 'rolldown/parseAst';
import * as estreeWalker from 'estree-walker';
import { assertNever, assertType } from '../utils.js';
import type { AstNode, ProgramNode } from 'rollup';
import type { ESTree as RolldownESTree } from 'rolldown/utils';
import type { AstNode } from 'rollup';
import type * as estree from 'estree';
import type { LocaleInliner, TextModification } from '../locale-inliner.js';
import type { Logger } from '../logger.js';
Expand All @@ -17,7 +18,7 @@ interface WalkerContext {
}

export function collectModifications(sourceCode: string, fileName: string, fileLogger: Logger, inliner: LocaleInliner): TextModification[] {
let programNode: ProgramNode;
let programNode: RolldownESTree.Program;
try {
programNode = parseAst(sourceCode);
} catch (err) {
Expand All @@ -35,7 +36,8 @@ export function collectModifications(sourceCode: string, fileName: string, fileL
// 1) replace all `scripts/` path literals with locale code
// 2) replace all `localStorage.getItem("lang")` with `localeName` variable
// 3) replace all `await window.fetch(`/assets/locales/${d}.${x}.json`).then(u=>u.json())` with `localeJson` variable
estreeWalker.walk(programNode, {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(estreeWalker.walk as any)(programNode, {
enter(this: WalkerContext, node: Node) {
assertType<AstNode>(node);

Expand Down Expand Up @@ -118,8 +120,9 @@ export function collectModifications(sourceCode: string, fileName: string, fileL
// Check if the identifier is already declared in the file.
// If it is, we may overwrite it and cause issues so we skip inlining
let isSupported = true;
estreeWalker.walk(programNode, {
enter(node) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(estreeWalker.walk as any)(programNode, {
enter(node: Node) {
if (node.type === 'VariableDeclaration') {
assertType<estree.VariableDeclaration>(node);
for (const id of node.declarations.flatMap(x => declsOfPattern(x.id))) {
Expand All @@ -145,8 +148,9 @@ export function collectModifications(sourceCode: string, fileName: string, fileL

const toSkip = new Set();
toSkip.add(i18nImport);
estreeWalker.walk(programNode, {
enter(this: WalkerContext, node, parent, property) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(estreeWalker.walk as any)(programNode, {
enter(this: WalkerContext, node: Node, parent: Node | null, property: string | number | symbol | null | undefined) {
assertType<AstNode>(node);
assertType<AstNode>(parent);
if (toSkip.has(node)) {
Expand Down Expand Up @@ -379,7 +383,7 @@ type SpecifierResult =
| { type: 'specifier', localI18nIdentifier: string, importNode: estree.ImportDeclaration & AstNode }
;

function findImportSpecifier(programNode: ProgramNode, i18nFileName: string, i18nSymbol: string): SpecifierResult {
function findImportSpecifier(programNode: RolldownESTree.Program, i18nFileName: string, i18nSymbol: string): SpecifierResult {
const imports = programNode.body.filter(x => x.type === 'ImportDeclaration');
const importNode = imports.find(x => x.source.value === `./${i18nFileName}`) as estree.ImportDeclaration | undefined;
if (!importNode) return { type: 'no-import' };
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"rollup": "4.60.0"
},
"dependencies": {
"i18n": "workspace:*",
"estree-walker": "3.0.3",
"i18n": "workspace:*",
"magic-string": "0.30.21",
"vite": "7.3.1"
"rolldown": "1.0.0-rc.11",
"vite": "8.0.2"
}
}
27 changes: 13 additions & 14 deletions packages/frontend-builder/rollup-plugin-remove-unref-i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

import * as estreeWalker from 'estree-walker';
import MagicString from 'magic-string';
import { RolldownMagicString } from 'rolldown';
import { assertType } from './utils.js';
import type { ESTree } from 'rolldown/utils';
import type { Plugin } from 'vite';
import type { CallExpression, Expression, Program } from 'estree';
import type { AstNode } from 'rollup';
import type { CallExpression, Expression } from 'estree';

// This plugin transforms `unref(i18n)` to `i18n` in the code, which is useful for removing unnecessary unref calls
// and helps locale inliner runs after vite build to inline the locale data into the final build.
Expand All @@ -23,31 +23,30 @@ export function pluginRemoveUnrefI18n(
} = {}): Plugin {
return {
name: 'UnwindCssModuleClassName',
renderChunk(code) {
renderChunk(code, _chunk, _options, meta) {
if (!code.includes('unref(i18n)')) return null;
const ast = this.parse(code) as Program;
const magicString = new MagicString(code);
estreeWalker.walk(ast, {
enter(node) {
const ast = this.parse(code);
const magicString = meta.magicString ?? new RolldownMagicString(code);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(estreeWalker.walk as any)(ast, {
enter(node: ESTree.Node) {
if (node.type === 'CallExpression' && node.callee.type === 'Identifier' && node.callee.name === 'unref'
&& node.arguments.length === 1) {
// calls to unref with single argument
const arg = node.arguments[0];
if (arg.type === 'Identifier' && arg.name === i18nSymbolName) {
// this is unref(i18n) so replace it with i18n
// to replace, remove the 'unref(' and the trailing ')'
assertType<CallExpression & AstNode>(node);
assertType<Expression & AstNode>(arg);
assertType<CallExpression>(node);
assertType<Expression>(arg);
magicString.remove(node.start, arg.start);
magicString.remove(arg.end, node.end);
}
}
},
});
return {
code: magicString.toString(),
map: magicString.generateMap({ hires: true }),
};

return magicString;
},
};
}
2 changes: 1 addition & 1 deletion packages/frontend-embed/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import url from 'node:url';
import path from 'node:path';
import { execa } from 'execa';
import locales from 'i18n';
import { LocaleInliner } from '../frontend-builder/locale-inliner.js'
import { LocaleInliner } from '../frontend-builder/locale-inliner.js';
import { createLogger } from '../frontend-builder/logger';

// requires node 21 or later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Original: https://github.com/rollup/plugins/tree/8835dd2aed92f408d7dc72d7cc25a9728e16face/packages/json
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/

import JSON5 from 'json5';
import { Plugin } from 'rollup';
import { Plugin } from 'vite';
import { createFilter, dataToEsm } from '@rollup/pluginutils';
import { RollupJsonOptions } from '@rollup/plugin-json';

Expand Down
5 changes: 2 additions & 3 deletions packages/frontend-embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"dependencies": {
"@discordapp/twemoji": "16.0.1",
"@rollup/plugin-json": "6.1.0",
"@rollup/plugin-replace": "6.0.3",
"@rollup/pluginutils": "5.3.0",
"@twemoji/parser": "16.0.0",
"@vitejs/plugin-vue": "6.0.5",
Expand All @@ -26,11 +25,9 @@
"misskey-js": "workspace:*",
"punycode.js": "2.3.1",
"rollup": "4.60.0",
"sass": "1.98.0",
"shiki": "3.23.0",
"tinycolor2": "1.6.0",
"uuid": "13.0.0",
"vite": "7.3.1",
"vue": "3.5.30"
},
"devDependencies": {
Expand All @@ -57,8 +54,10 @@
"msw": "2.12.14",
"nodemon": "3.1.14",
"prettier": "3.8.1",
"sass-embedded": "1.98.0",
"start-server-and-test": "2.1.5",
"tsx": "4.21.0",
"vite": "8.0.2",
"vite-plugin-turbosnap": "1.0.3",
"vue-component-type-helpers": "3.2.6",
"vue-eslint-parser": "10.4.0",
Expand Down
27 changes: 15 additions & 12 deletions packages/frontend-embed/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { promises as fsp } from 'fs';
import locales from 'i18n';
import meta from '../../package.json';
import packageInfo from './package.json' with { type: 'json' };
import pluginJson5 from './vite.json5.js';
import pluginJson5 from './lib/vite-plugin-json5.js';
import { pluginRemoveUnrefI18n } from '../frontend-builder/rollup-plugin-remove-unref-i18n';

const url = process.env.NODE_ENV === 'development' ? yaml.load(await fsp.readFile('../../.config/default.yml', 'utf-8')).url : null;
const url = process.env.NODE_ENV === 'development' ? (yaml.load(await fsp.readFile('../../.config/default.yml', 'utf-8')) as any).url : null;
const host = url ? (new URL(url)).hostname : undefined;

const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
Expand Down Expand Up @@ -113,11 +113,6 @@ export function getConfig(): UserConfig {
}
},
},
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},

define: {
Expand All @@ -137,18 +132,26 @@ export function getConfig(): UserConfig {
'safari16',
],
manifest: 'manifest.json',
rollupOptions: {
rolldownOptions: {
experimental: {
nativeMagicString: true,
},
input: {
i18n: './src/i18n.ts',
entry: './src/boot.ts',
},
external: externalPackages.map(p => p.match),
preserveEntrySignatures: 'allow-extension',
output: {
manualChunks: {
vue: ['vue'],
// dependencies of i18n.ts
'config': ['@@/js/config.js'],
codeSplitting: {
groups: [{
name: 'vue',
test: /node_modules[\\/]vue/,
}, {
// dependencies of i18n.ts
name: 'config',
test: /@@[\\/]js[\\/]config\.js/,
}],
},
entryFileNames: `scripts/${localesHash}-[hash:8].js`,
chunkFileNames: `scripts/${localesHash}-[hash:8].js`,
Expand Down
Loading
Loading