ultraq / thymeleafjs

A basic implementation of the Thymeleaf templating engine in JavaScript
Apache License 2.0
52 stars 8 forks source link

Have devs specify their own template resolution function? #22

Closed ultraq closed 6 years ago

ultraq commented 6 years ago

This warning comes up when using the in-dev version of thymeleafjs with Webpack:

WARNING in /Users/Scanner/Documents/Programming/thymeleafjs/lib/thymeleaf.browser.es.js
3653:37-58 Critical dependency: the request of a dependency is an expression
 @ /Users/Scanner/Documents/Programming/thymeleafjs/lib/thymeleaf.browser.es.js
 @ ./source/scripts/TemplateEngine.js
 @ ./source/scripts/Todo.js

Sounds pretty bad, but it's not. It effectively means it found a require call, yet the argument to it is a variable rather than a string - webpack complains when it can't statically analyze a dependency and so emits this warning.

It's not nice to see that come out of the library code, so maybe I should push the resolution function back onto consuming apps so that devs can decide how they want to deal with them? But that would mean devs would have to write the same boilerplate code all the time...

ultraq commented 6 years ago

Yep, just tried it out and I think it's much better: devs now in full control of how to resolve templates via their own choice of tools/code, and the library is no longer emitting warnings outside of their control.