-
-
Notifications
You must be signed in to change notification settings - Fork 399
Description
The loadCustomControllers function iterates over all .ts and .js files in the project's controllers path to build a controller map.
My project has a build step where TypeScript controllers are transpiled to JavaScript files that are saved alongside the source TypeScript files. My asset mapper config excludes TypeScript files since I'm only interested in serving JavaScript.
When loadCustomControllers iterates over all .ts and .js files in my controllers path, it tries to load mapped assets for my .ts controllers. But since these files are excluded, the returned asset is null and an exception is thrown when it tries to read the sourcePath property on the null asset.
Controller files should be a mapped asset. Not finding one indicates a problem so an exception should be thrown (e.g. see null mapped asset check in loadUxControllers function). However the loadCustomControllers function doesn't realize there are .js and .ts versions of the same controller and can skip processing the missing version.
I expected that I could exclude .ts controller files when .js versions are available.
Here's my proposed fix:
- Skip mapping
.tscontroller file if a.jsversion is available - Add a null asset check and throw an exception similar to one thrown in
loadUxControllers
Related: #1210