Tengo un proyecto en el que estoy tratando de instalar componentes de estímulo y viento de cola de estímulo.
Agregué webpack y un archivo de configuración de webpack:
// Webpack uses this to work with directories const path = require('path'); // This is the main configuration object. // Here, you write different options and tell Webpack what to do module.exports = { module: { rules: [ { test: /\.js$/, exclude: /(node_modules)/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'] } } } ], }, // Path to your entry point. From this file Webpack will begin its work entry: './src/js/index.js', // Path and filename of your result bundle. // Webpack will bundle all JavaScript into this file output: { path: path.resolve(__dirname, 'dist'), publicPath: '', filename: 'bundle.js' }, // Default mode for Webpack is production. // Depending on mode Webpack will apply different things // on the final bundle. For now, we don't need production's JavaScript // minifying and other things, so let's set mode to development mode: 'development' };Por lo que entiendo, usar babel debería transpilar mi es6 js a js compatible con el navegador.
Luego, en src/index.js tengo el código de estímulo:
// Iniciar EstímuloJS
import { Application } from "@hotwired/stimulus" const application = Application.start(); // Import and register all TailwindCSS Components import { Alert, Autosave, Dropdown, Modal, Tabs, Popover, Toggle, Slideover } from "tailwindcss-stimulus-components" application.register('alert', Alert) application.register('autosave', Autosave) application.register('dropdown', Dropdown) application.register('modal', Modal) application.register('tabs', Tabs) application.register('popover', Popover) application.register('toggle', Toggle) application.register('slideover', Slideover)y en el archivo html necesito mi bundle.js:
<script src="../dist/bundle.js"></script>Sin embargo, sigo recibiendo este error:
No capturado (en promesa) TypeError: el controlador del constructor de clase no se puede invocar sin 'nuevo' de tailwindcss-stimulus-components.module.js: 12
Aquí hay un enlace al proyecto .
¿Hay algún problema con la configuración de mi paquete web? ¿Cómo puedo solucionar este error?