From 7abca031225c3daeb19fce885a1d6908dd6cfc8c Mon Sep 17 00:00:00 2001 From: thibaud-leclere Date: Sat, 28 Mar 2026 13:51:54 +0100 Subject: [PATCH] fix: drop react-swc plugin for esbuild JSX and add vite-bundle routes Use esbuild's built-in JSX transform instead of @vitejs/plugin-react-swc to fix the React Fast Refresh preamble error caused by eager glob imports. Add missing pentatrion_vite routes to fix web debug toolbar 500 errors. Co-Authored-By: Claude Opus 4.6 --- config/reference.php | 32 ++++++++++++++++++++++++++++++ config/routes/pentatrion_vite.yaml | 9 +++++++++ vite.config.js | 10 +++++++--- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 config/routes/pentatrion_vite.yaml diff --git a/config/reference.php b/config/reference.php index 0d08ceb..11989e5 100644 --- a/config/reference.php +++ b/config/reference.php @@ -1459,6 +1459,34 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * controllers_path?: scalar|null|Param, // The path to the directory where React controller components are stored - relevant only when using symfony/asset-mapper. // Default: "%kernel.project_dir%/assets/react/controllers" * name_glob?: list, * } + * @psalm-type PentatrionViteConfig = array{ + * public_directory?: scalar|null|Param, // Default: "public" + * build_directory?: scalar|null|Param, // we only need build_directory to locate entrypoints.json file, it's the "base" vite config parameter without slashes. // Default: "build" + * proxy_origin?: scalar|null|Param, // Allows to use different origin for asset proxy, eg. http://host.docker.internal:5173 // Default: null + * absolute_url?: bool|Param, // Prepend the rendered link and script tags with an absolute URL. // Default: false + * throw_on_missing_entry?: scalar|null|Param, // Throw exception when entry is not present in the entrypoints file // Default: false + * throw_on_missing_asset?: scalar|null|Param, // Throw exception when asset is not present in the manifest file // Default: true + * cache?: bool|Param, // Enable caching of the entry point file(s) // Default: false + * preload?: "none"|"link-tag"|"link-header"|Param, // preload all rendered script and link tags automatically via the http2 Link header. (symfony/web-link is required) Instead will be used. // Default: "link-tag" + * crossorigin?: false|true|"anonymous"|"use-credentials"|Param, // crossorigin value, can be false, true (default), anonymous (same as true) or use-credentials // Default: true + * script_attributes?: list, + * link_attributes?: list, + * preload_attributes?: list, + * default_build?: scalar|null|Param, // Deprecated: The "default_build" option is deprecated. Use "default_config" instead. // Default: null + * builds?: array, + * link_attributes?: list, + * preload_attributes?: list, + * }>, + * default_config?: scalar|null|Param, // Default: null + * configs?: array, + * link_attributes?: list, + * preload_attributes?: list, + * }>, + * } * @psalm-type ConfigType = array{ * imports?: ImportsConfig, * parameters?: ParametersConfig, @@ -1473,6 +1501,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * security?: SecurityConfig, * monolog?: MonologConfig, * react?: ReactConfig, + * pentatrion_vite?: PentatrionViteConfig, * "when@dev"?: array{ * imports?: ImportsConfig, * parameters?: ParametersConfig, @@ -1490,6 +1519,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * monolog?: MonologConfig, * maker?: MakerConfig, * react?: ReactConfig, + * pentatrion_vite?: PentatrionViteConfig, * }, * "when@prod"?: array{ * imports?: ImportsConfig, @@ -1505,6 +1535,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * security?: SecurityConfig, * monolog?: MonologConfig, * react?: ReactConfig, + * pentatrion_vite?: PentatrionViteConfig, * }, * "when@test"?: array{ * imports?: ImportsConfig, @@ -1521,6 +1552,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param; * security?: SecurityConfig, * monolog?: MonologConfig, * react?: ReactConfig, + * pentatrion_vite?: PentatrionViteConfig, * }, * ...