Files
ltbxd-actorle/assets/bootstrap.js
thibaud-leclere f42a3ba286 fix: manually register Stimulus controllers in bootstrap.js
Auto-discovery may not work reliably with vite-plugin-symfony.
Explicit registration ensures dropdown, notifications, and
import-modal controllers are loaded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 23:14:16 +02:00

26 lines
1.2 KiB
JavaScript

import { startStimulusApp } from 'vite-plugin-symfony/stimulus/helpers';
import DropdownController from './controllers/dropdown_controller.js';
import NotificationsController from './controllers/notifications_controller.js';
import ImportModalController from './controllers/import_modal_controller.js';
const app = startStimulusApp();
app.register('dropdown', DropdownController);
app.register('notifications', NotificationsController);
app.register('import-modal', ImportModalController);
// Register React components for {{ react_component() }} Twig function.
// We register them manually because @symfony/ux-react's registerReactControllerComponents
// expects Webpack's require.context API, which is not available in Vite.
const reactControllers = import.meta.glob('./react/controllers/**/*.jsx', { eager: true });
window.resolveReactComponent = (name) => {
const key = `./react/controllers/${name}.jsx`;
const module = reactControllers[key];
if (!module) {
const available = Object.keys(reactControllers)
.map(k => k.replace('./react/controllers/', '').replace('.jsx', ''));
throw new Error(`React controller "${name}" does not exist. Possible values: ${available.join(', ')}`);
}
return module;
};