dailymuse / mithril-coat

A minimalistic frontend web framework that builds on Mithril.
BSD 3-Clause "New" or "Revised" License
28 stars 3 forks source link

Strangeness when moving a file #1

Closed ysimonson closed 9 years ago

ysimonson commented 9 years ago

I moved a template from one directory to another, and updated the reference to it in a coffeescript file that was using it. When I did so, I got this error:

compiled /Users/ysimonson/Desktop/dailymuse/themuse/static/scripts/admin/task.js
Cannot find module '../../components/admin/progress_bar.js' from '/Users/ysimonson/Desktop/dailymuse/themuse/static/templates/apps/admin'

task.js is empty, so it didn't compile. The error on the second line should probably provide more context, because it wasn't clear that the error was actually coming from something else that was referencing the template - another template.

When I updated that template, I got this this:

Compiled `assets/templates/apps/admin/task.html` to `static/templates/apps/admin/task.js`

And looking at the source code of the template, it looks like it compiled fine. Cool. But my task.js is still empty. I tried re-saving the associated coffeescript file to see if it just missed the update, but I'm still getting an error:

compiled /Users/ysimonson/Desktop/dailymuse/themuse/static/scripts/admin/task.js
Cannot find module 'progress_bar.js' from '/Users/ysimonson/Desktop/dailymuse/themuse/static/templates/apps/admin'

This is strange because there is indeed a progress_bar.js at that path:

$ ls /Users/ysimonson/Desktop/dailymuse/themuse/static/templates/apps/admin/progress_bar.js 
/Users/ysimonson/Desktop/dailymuse/themuse/static/templates/apps/admin/progress_bar.js

So it appears the errors are two-fold:

1) mithril-coat erroneously reporting that it successfully compiled a file, when it didn't. 2) Some sort of bug in the dependency resolvers, such that the templates can compile successfully, but any coffeescript files referencing those successfully compiling templates fail to compile themselves.

ysimonson commented 9 years ago

Update: the fix was to change the reference progress_bar.js in the template to ./progress_bar.js. But interestingly enough, it didn't work until mithril-coat's template watcher was restarted. The need to restart is a bug, but I'd argue that it's also a bug to not consider progress_bar.js to be the same thing as ./progress_bar.js.

sdalezman commented 9 years ago

Thanks for the update.

I agree that it's a bug that to not consider progress_bar.js the same thing as ./progress_bar.js. Will push out a fix soon.

This bug also sounds like error reporting needs to be a bit more refined for template errors.