diff --git a/vite.config.mts b/vite.config.mts index 0477177078c..11a4b1f5e66 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -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 = ['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(),