Skip to content

Commit 1935f4d

Browse files
Update dependency vite to v8 (mastodon#38174)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: ChaosExAnima <ChaosExAnima@users.noreply.github.com>
1 parent d48470a commit 1935f4d

8 files changed

Lines changed: 1142 additions & 1071 deletions

File tree

.storybook/vitest.setup.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/javascript/mastodon/features/emoji/worker.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
import { EMOJI_DB_NAME_SHORTCODES, EMOJI_TYPE_CUSTOM } from './constants';
2-
import {
3-
importCustomEmojiData,
4-
importEmojiData,
5-
importLegacyShortcodes,
6-
} from './loader';
72

83
addEventListener('message', handleMessage);
94
self.postMessage('ready'); // After the worker is ready, notify the main thread
@@ -16,6 +11,8 @@ function handleMessage(event: MessageEvent<{ locale: string }>) {
1611
}
1712

1813
async function loadData(locale: string) {
14+
const { importCustomEmojiData, importEmojiData, importLegacyShortcodes } =
15+
await import('./loader');
1916
let importCount: number | undefined;
2017
if (locale === EMOJI_TYPE_CUSTOM) {
2118
importCount = (await importCustomEmojiData())?.length;

app/javascript/testing/api.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ export const mockHandlers = {
5151
'/packs-dev/emoji/:locale.json',
5252
async ({ params }) => {
5353
const locale = toSupportedLocale(params.locale);
54+
const key = `../../../../../node_modules/emojibase-data/${locale}/compact.json`;
55+
const emojiModules = import.meta.glob<CompactEmoji[]>(
56+
'../../../../../node_modules/emojibase-data/**/compact.json',
57+
{ import: 'default' },
58+
);
59+
const path = emojiModules[key];
60+
if (!path) {
61+
throw new Error(`Unsupported locale: ${locale}`);
62+
}
5463
action('fetching emoji data')(locale);
55-
const { default: data } = (await import(
56-
/* @vite-ignore */
57-
`emojibase-data/${locale}/compact.json`
58-
)) as {
59-
default: CompactEmoji[];
60-
};
64+
const data = await path();
6165

6266
return HttpResponse.json([data]);
6367
},

config/vite/plugin-mastodon-themes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function MastodonThemes(): Plugin {
2424

2525
let entrypoints: Record<string, string> = {};
2626

27-
const existingInputs = userConfig.build?.rollupOptions?.input;
27+
const existingInputs = userConfig.build?.rolldownOptions?.input;
2828

2929
if (typeof existingInputs === 'string') {
3030
entrypoints[path.basename(existingInputs)] = existingInputs;
@@ -46,7 +46,7 @@ export function MastodonThemes(): Plugin {
4646

4747
return {
4848
build: {
49-
rollupOptions: {
49+
rolldownOptions: {
5050
input: entrypoints,
5151
},
5252
},

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
5151
"@optimize-lodash/rollup-plugin": "^6.0.0",
5252
"@react-spring/web": "^9.7.5",
5353
"@reduxjs/toolkit": "^2.0.1",
54+
"@rolldown/plugin-babel": "^0.2.2",
5455
"@use-gesture/react": "^10.3.1",
55-
"@vitejs/plugin-legacy": "^7.2.1",
56+
"@vitejs/plugin-legacy": "^8.0.0",
5657
"@vitejs/plugin-react": "^5.0.0",
5758
"arrow-key-navigation": "^1.2.0",
5859
"async-mutex": "^0.5.0",
@@ -108,8 +109,8 @@
108109
"redux-immutable": "^4.0.0",
109110
"regenerator-runtime": "^0.14.0",
110111
"requestidlecallback": "^0.3.0",
111-
"rollup-plugin-gzip": "^4.1.1",
112-
"rollup-plugin-visualizer": "^6.0.3",
112+
"rollup-plugin-gzip": "^4.2.0",
113+
"rollup-plugin-visualizer": "^7.0.1",
113114
"sass": "^1.62.1",
114115
"scroll-behavior": "^0.11.0",
115116
"stacktrace-js": "^2.0.2",
@@ -119,11 +120,10 @@
119120
"tiny-queue": "^0.2.1",
120121
"twitter-text": "3.1.0",
121122
"use-debounce": "^10.0.0",
122-
"vite": "^7.1.1",
123+
"vite": "^8.0.0",
123124
"vite-plugin-manifest-sri": "^0.2.0",
124-
"vite-plugin-pwa": "^1.0.2",
125-
"vite-plugin-svgr": "^4.3.0",
126-
"vite-tsconfig-paths": "^6.0.0",
125+
"vite-plugin-pwa": "^1.2.0",
126+
"vite-plugin-svgr": "^4.5.0",
127127
"wicg-inert": "^3.1.2",
128128
"workbox-expiration": "^7.3.0",
129129
"workbox-routing": "^7.3.0",
@@ -133,10 +133,10 @@
133133
"devDependencies": {
134134
"@eslint/js": "^9.39.2",
135135
"@formatjs/cli": "^6.1.1",
136-
"@storybook/addon-a11y": "^10.0.6",
137-
"@storybook/addon-docs": "^10.0.6",
138-
"@storybook/addon-vitest": "^10.0.6",
139-
"@storybook/react-vite": "^10.0.6",
136+
"@storybook/addon-a11y": "^10.3.0",
137+
"@storybook/addon-docs": "^10.3.0",
138+
"@storybook/addon-vitest": "^10.3.0",
139+
"@storybook/react-vite": "^10.3.0",
140140
"@testing-library/dom": "^10.4.1",
141141
"@testing-library/react": "^16.3.0",
142142
"@types/debug": "^4",
@@ -161,10 +161,10 @@
161161
"@types/react-toggle": "^4.0.3",
162162
"@types/redux-immutable": "^4.0.3",
163163
"@types/requestidlecallback": "^0.3.5",
164-
"@vitest/browser": "^4.0.5",
165-
"@vitest/browser-playwright": "^4.0.5",
166-
"@vitest/coverage-v8": "^4.0.5",
167-
"@vitest/ui": "^4.0.5",
164+
"@vitest/browser": "^4.1.0",
165+
"@vitest/browser-playwright": "^4.1.0",
166+
"@vitest/coverage-v8": "^4.1.0",
167+
"@vitest/ui": "^4.1.0",
168168
"chromatic": "^13.3.3",
169169
"eslint": "^9.39.2",
170170
"eslint-import-resolver-typescript": "^4.2.5",
@@ -185,13 +185,13 @@
185185
"oxfmt": "^0.33.0",
186186
"playwright": "^1.57.0",
187187
"react-test-renderer": "^18.2.0",
188-
"storybook": "^10.0.5",
188+
"storybook": "^10.3.0",
189189
"stylelint": "^17.0.0",
190190
"stylelint-config-standard-scss": "^17.0.0",
191191
"typescript": "~5.9.0",
192192
"typescript-eslint": "^8.55.0",
193193
"typescript-plugin-css-modules": "^5.2.0",
194-
"vitest": "^4.0.5"
194+
"vitest": "^4.1.0"
195195
},
196196
"resolutions": {
197197
"@types/react": "^18.2.7",

vite.config.mts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { readdir } from 'node:fs/promises';
22
import path from 'node:path';
33

44
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
5+
import babel from '@rolldown/plugin-babel';
56
import legacy from '@vitejs/plugin-legacy';
67
import react from '@vitejs/plugin-react';
78
import postcssPresetEnv from 'postcss-preset-env';
@@ -16,7 +17,6 @@ import {
1617
import manifestSRI from 'vite-plugin-manifest-sri';
1718
import { VitePWA } from 'vite-plugin-pwa';
1819
import svgr from 'vite-plugin-svgr';
19-
import tsconfigPaths from 'vite-tsconfig-paths';
2020

2121
import { MastodonAssetsManifest } from './config/vite/plugin-assets-manifest';
2222
import { MastodonEmojiCompressed } from './config/vite/plugin-emoji-compressed';
@@ -44,6 +44,7 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => {
4444
base: `/${outDirName}/`,
4545
envDir: __dirname,
4646
resolve: {
47+
tsconfigPaths: true,
4748
alias: {
4849
'~/': `${jsRoot}/`,
4950
'@/': `${jsRoot}/`,
@@ -122,7 +123,7 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => {
122123
assetsDir: 'assets',
123124
assetsInlineLimit: (filePath, _) =>
124125
/\.woff2?$/.exec(filePath) ? false : undefined,
125-
rollupOptions: {
126+
rolldownOptions: {
126127
input: await findEntrypoints(),
127128
output: {
128129
chunkFileNames({ facadeModuleId, name }) {
@@ -168,11 +169,9 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => {
168169
format: 'es',
169170
},
170171
plugins: [
171-
tsconfigPaths({ projects: [path.resolve(__dirname, 'tsconfig.json')] }),
172-
react({
173-
babel: {
174-
plugins: ['formatjs', 'transform-react-remove-prop-types'],
175-
},
172+
react(),
173+
babel({
174+
plugins: ['formatjs', 'transform-react-remove-prop-types'],
176175
}),
177176
MastodonThemes(),
178177
MastodonAssetsManifest(),

vitest.config.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const storybookTests: TestProjectInlineConfiguration = {
2727
provider: playwright(),
2828
instances: [{ browser: 'chromium' }],
2929
},
30-
setupFiles: [resolve(__dirname, '.storybook/vitest.setup.ts')],
3130
},
3231
};
3332

0 commit comments

Comments
 (0)