mirror of
https://github.com/mastodon/mastodon.git
synced 2026-09-27 05:47:04 -05:00
Update vite/babel config to avoid parsing files which dont have propTypes refs (#40669)
This commit is contained in:
@@ -3,7 +3,7 @@ import path from 'node:path';
|
||||
|
||||
import formatjs from '@formatjs/unplugin/vite';
|
||||
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
|
||||
import babel from '@rolldown/plugin-babel';
|
||||
import babel, { defineRolldownBabelPreset } from '@rolldown/plugin-babel';
|
||||
import legacy from '@vitejs/plugin-legacy';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import browserslist from 'browserslist';
|
||||
@@ -28,6 +28,16 @@ const jsRoot = path.resolve(import.meta.dirname, 'app/javascript');
|
||||
|
||||
const cssAliasClasses: ReadonlyArray<string> = ['components', 'features'];
|
||||
|
||||
// Avoid parsing files which don't reference `propTypes`
|
||||
const removePropTypesPreset = defineRolldownBabelPreset({
|
||||
preset: () => ({ plugins: ['transform-react-remove-prop-types'] }),
|
||||
rolldown: {
|
||||
filter: {
|
||||
code: /propTypes/i,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const config: UserConfigFnPromise = async ({ mode, command }) => {
|
||||
const isProdBuild = mode === 'production' && command === 'build';
|
||||
|
||||
@@ -181,7 +191,7 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => {
|
||||
plugins: [
|
||||
react(),
|
||||
babel({
|
||||
plugins: ['transform-react-remove-prop-types'],
|
||||
presets: [removePropTypesPreset],
|
||||
}),
|
||||
formatjs(),
|
||||
MastodonThemes(),
|
||||
|
||||
Reference in New Issue
Block a user