{"action":"created","issue":{"url":"https://api.github.com/repos/lasso-js/lasso/issues/105","repository_url":"https://api.github.com/repos/lasso-js/lasso","labels_url":"https://api.github.com/repos/lasso-js/lasso/issues/105/labels{/name}","comments_url":"https://api.github.com/repos/lasso-js/lasso/issues/105/comments","events_url":"https://api.github.com/repos/lasso-js/lasso/issues/105/events","html_url":"https://github.com/lasso-js/lasso/issues/105","id":131510050,"number":105,"title":"<lasso-img/> paths break if called within a node_module dependency","user":{"login":"tropperstyle","id":28314,"avatar_url":"https://avatars.githubusercontent.com/u/28314?v=3","gravatar_id":"","url":"https://api.github.com/users/tropperstyle","html_url":"https://github.com/tropperstyle","followers_url":"https://api.github.com/users/tropperstyle/followers","following_url":"https://api.github.com/users/tropperstyle/following{/other_user}","gists_url":"https://api.github.com/users/tropperstyle/gists{/gist_id}","starred_url":"https://api.github.com/users/tropperstyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tropperstyle/subscriptions","organizations_url":"https://api.github.com/users/tropperstyle/orgs","repos_url":"https://api.github.com/users/tropperstyle/repos","events_url":"https://api.github.com/users/tropperstyle/events{/privacy}","received_events_url":"https://api.github.com/users/tropperstyle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-04T23:52:59Z","updated_at":"2016-02-05T23:22:29Z","closed_at":null,"body":"```\r\nTypeError: Cannot read property 'url' of undefined\r\n    at /app/node_modules/lasso/node_modules/lasso-image/lasso-image.js:93:61\r\n    at /app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:247:24\r\n    at /app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:111:25\r\n    at done (/app/node_modules/lasso/lib/Lasso.js:302:20)\r\n    at doLassoResource (/app/node_modules/lasso/lib/Lasso.js:343:20)\r\n    at /app/node_modules/lasso/lib/Lasso.js:737:21\r\n    at /app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:107:17\r\n    at Object.MemoryStore.get (/app/node_modules/lasso/node_modules/raptor-cache/lib/MemoryStore.js:14:16)\r\n    at getCacheEntry (/app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:62:22)\r\n    at Cache.get (/app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:245:9)\r\n    at Object.LassoCache.getLassoedResource (/app/node_modules/lasso/lib/LassoCache.js:126:43)\r\n    at Lasso.lassoResource (/app/node_modules/lasso/lib/Lasso.js:734:19)\r\n    at work (/app/node_modules/lasso/node_modules/lasso-image/lasso-image.js:92:38)\r\n    at parallel (/app/node_modules/lasso/node_modules/raptor-async/parallel.js:57:21)\r\n    at cache.get.builder (/app/node_modules/lasso/node_modules/lasso-image/lasso-image.js:111:21)\r\n    at /app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:107:17\r\n    at Object.MemoryStore.get (/app/node_modules/lasso/node_modules/raptor-cache/lib/MemoryStore.js:14:16)\r\n    at getCacheEntry (/app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:62:22)\r\n    at Cache.get (/app/node_modules/lasso/node_modules/raptor-cache/lib/Cache.js:245:9)\r\n    at /app/node_modules/lasso/node_modules/lasso-image/lasso-image.js:84:15\r\n    at Object.<anonymous> (/app/node_modules/lasso/node_modules/raptor-modules/util/lib/caching-fs.js:75:9)\r\n    at notifyCallbacks (/app/node_modules/lasso/node_modules/raptor-async/AsyncValue.js:76:35)\r\n    at Object.AsyncValue.resolve (/app/node_modules/lasso/node_modules/raptor-async/AsyncValue.js:262:9)\r\n    at /app/node_modules/lasso/node_modules/raptor-modules/util/lib/caching-fs.js:40:24\r\n    at FSReqWrap.oncomplete (fs.js:82:15)\r\n```\r\n\r\nA potential fit seems to lie around [lasso-img-tag-transformer.js#L14](https://github.com/lasso-js/lasso/blob/master/taglib/lasso-img-tag-transformer.js#L14)\r\n\r\nBut I tried wrapping the second argument passed to setAttribute with `require('path').resolve(template.dirname, ...)` and the way that failed leaves me questioning if this line is really the right entry point. \r\n\r\nCurrent workaround:\r\n`<lasso-img src=\"./relative/path.png\"/>` => `<lasso-img src=\"${__dirname}/relative/path.png\"/>`"},"comment":{"url":"https://api.github.com/repos/lasso-js/lasso/issues/comments/180618255","html_url":"https://github.com/lasso-js/lasso/issues/105#issuecomment-180618255","issue_url":"https://api.github.com/repos/lasso-js/lasso/issues/105","id":180618255,"user":{"login":"patrick-steele-idem","id":978214,"avatar_url":"https://avatars.githubusercontent.com/u/978214?v=3","gravatar_id":"","url":"https://api.github.com/users/patrick-steele-idem","html_url":"https://github.com/patrick-steele-idem","followers_url":"https://api.github.com/users/patrick-steele-idem/followers","following_url":"https://api.github.com/users/patrick-steele-idem/following{/other_user}","gists_url":"https://api.github.com/users/patrick-steele-idem/gists{/gist_id}","starred_url":"https://api.github.com/users/patrick-steele-idem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrick-steele-idem/subscriptions","organizations_url":"https://api.github.com/users/patrick-steele-idem/orgs","repos_url":"https://api.github.com/users/patrick-steele-idem/repos","events_url":"https://api.github.com/users/patrick-steele-idem/events{/privacy}","received_events_url":"https://api.github.com/users/patrick-steele-idem/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T23:22:29Z","updated_at":"2016-02-05T23:22:29Z","body":"> Wouldn't the root fix be to alter the output of the compiled template? Something like:\r\n\r\nYes, but `require.resolve` is actually pretty slow (even though it is cached). We could add `require.resolve` if we detect that the image path is dynamic, but... It wouldn't allow the same code to work on the server since Lasso.js wouldn't know to include the image info for a dynamic path like that.\r\n\r\nYour workaround is good as long as you are okay with the code only working on the server."}}