-
Notifications
You must be signed in to change notification settings - Fork 248
Template cache generator doesn't resolve templates the same way angular does. #750
Comments
This commit is the culprit: f918d4d I'm unable to specify a templateUrl that both angular can resolve at runtime and the template_cache_generator can resolve. |
tl;dr; Simple fix would be to change the URL to an absolute URL. Commit f918d4d was a fix to start processing parts of library definitions. Prior to this the Now that the component is being processed the system thinks the file path is relative. For path relative URIs it uses the src component to determine the relative path, but this is problematic as it is relative to the current source and not context URI. That being said context URI would be pretty hard to determine when generating the cache. Imagine a simple component that was used multiple locations. What would be the correct URI to determine the relative path? It would change depending on where the component was used. Unless it should always be root relative then I would argue absolute paths should be used to indicate this. For this reason components in the lib directory should be absolute urls pointing at the packages directory Your component works in angular as long as your context url path is root. Some relative URLs would work in the component was in the web directory depending on the context being used, but I largely avoid them. Some work is being done currently to allow you to use relative URIs from the component which would be much more useful in my opinion. |
The fix you propose only works when running the app normally. The template cache generator still fails to resolve it. |
The template_cache_generator isn't properly resolving templates. For example, I have
/lib/my_library.dart
/lib/src/components/chat_view.dart
/lib/src/components/chat_view.html
/web/entrypoint.dart
In
chat_view.dart
I'm specifying the templateUrl as follows:templateUrl: 'packages/my_library/src/components/chat_view.html
I notice the generator looks for the templates relative to the directory that contains the library file. In the case of the above configuration, it's looking for the template in
/lib/packages/my_library/src/components/chat_view.html
.Prior to 0.9.9, this configuration was working. I would expect the template cache generator look for templates relative to the entrypoint file, which if using proper conventions should be the web directory. Instead, it's looking for them relative to my library that was imported in the entrypoint.
I did some initial digging into recent changes but couldn't find the culprit. I'll keep looking in the meantime.
The text was updated successfully, but these errors were encountered: