File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import {
2- Application ,
3- Controller ,
4- ControllerConstructor ,
5- } from "@hotwired/stimulus" ;
1+ import { Application , ControllerConstructor } from "@hotwired/stimulus" ;
62import StimulusControllerResolver from "stimulus-controller-resolver" ;
73
84/**
@@ -16,7 +12,7 @@ export function startApp(...modules: AsyncModuleMap[]) {
1612 const allModules : AsyncModuleMap = Object . assign (
1713 { } ,
1814 EXPORTED_MODULES ,
19- ...modules
15+ ...modules ,
2016 ) ;
2117
2218 const resolver = createAsyncControllerResolver ( allModules ) ;
@@ -38,20 +34,25 @@ const createAsyncControllerResolver = (pathMap: AsyncModuleMap) => {
3834 }
3935
4036 return [ ] ;
41- } )
37+ } ) ,
4238 ) ;
4339
4440 return async ( key : string ) => {
4541 const module = await identifierMap [ key ] ?.( ) ;
4642 if ( ! module ) {
4743 throw Error (
48- `Controller not found: ${ key } . Have you named the file ${ key } -controller.ts?`
44+ `Controller not found: ${ key } . Have you named the file ${ key } -controller.ts?` ,
4945 ) ;
5046 }
5147
52- if ( ! module . default || ! ( module . default . prototype instanceof Controller ) ) {
48+ if (
49+ ! module . default ||
50+ typeof module . default !== "function" ||
51+ typeof module . default . prototype . connect !== "function" ||
52+ typeof module . default . prototype . disconnect !== "function"
53+ ) {
5354 throw Error (
54- `Module ${ key } should have as its default export a subclass of Controller`
55+ `Module ${ key } should have as its default export a subclass of Controller` ,
5556 ) ;
5657 }
5758
You can’t perform that action at this time.
0 commit comments