{"action":"created","issue":{"url":"https://api.github.com/repos/emaphp/underscore-template-loader/issues/19","repository_url":"https://api.github.com/repos/emaphp/underscore-template-loader","labels_url":"https://api.github.com/repos/emaphp/underscore-template-loader/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/emaphp/underscore-template-loader/issues/19/comments","events_url":"https://api.github.com/repos/emaphp/underscore-template-loader/issues/19/events","html_url":"https://github.com/emaphp/underscore-template-loader/issues/19","id":141443232,"number":19,"title":"Question about Requiring the Engine","user":{"login":"MattSurabian","id":1134260,"avatar_url":"https://avatars.githubusercontent.com/u/1134260?v=3","gravatar_id":"","url":"https://api.github.com/users/MattSurabian","html_url":"https://github.com/MattSurabian","followers_url":"https://api.github.com/users/MattSurabian/followers","following_url":"https://api.github.com/users/MattSurabian/following{/other_user}","gists_url":"https://api.github.com/users/MattSurabian/gists{/gist_id}","starred_url":"https://api.github.com/users/MattSurabian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattSurabian/subscriptions","organizations_url":"https://api.github.com/users/MattSurabian/orgs","repos_url":"https://api.github.com/users/MattSurabian/repos","events_url":"https://api.github.com/users/MattSurabian/events{/privacy}","received_events_url":"https://api.github.com/users/MattSurabian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-17T00:50:49Z","updated_at":"2016-03-17T02:12:36Z","closed_at":null,"body":"Thanks for a great webpack plugin! \r\n\r\nI recently refactored some code using this loader to no longer require the use of lodash's `templateSettings.imports` (and thus the `engine` config property) and was surprised to see how much that reduced the final size of the project's build and went digging. Wondering if @kmck or others could shed some light on [this chunk of code](https://github.com/emaphp/underscore-template-loader/blob/master/index.js#L114-L117). This was made as part of the PR that allowed support for lodash's template settings imports and I'm just curious why supporting that means the entirety of the lodash engine needs to be loaded into the final webpack bundle? Is it because the templates can't be fully compiled and stored until runtime or something?\r\n\r\nMy knee jerk reaction was to try and find a way to reduce the need for the entire engine to be loaded but pretty quickly realized I didn't have full context for the inner workings. Anyway, curious to learn a little more from yall."},"comment":{"url":"https://api.github.com/repos/emaphp/underscore-template-loader/issues/comments/197654892","html_url":"https://github.com/emaphp/underscore-template-loader/issues/19#issuecomment-197654892","issue_url":"https://api.github.com/repos/emaphp/underscore-template-loader/issues/19","id":197654892,"user":{"login":"kmck","id":1398194,"avatar_url":"https://avatars.githubusercontent.com/u/1398194?v=3","gravatar_id":"","url":"https://api.github.com/users/kmck","html_url":"https://github.com/kmck","followers_url":"https://api.github.com/users/kmck/followers","following_url":"https://api.github.com/users/kmck/following{/other_user}","gists_url":"https://api.github.com/users/kmck/gists{/gist_id}","starred_url":"https://api.github.com/users/kmck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmck/subscriptions","organizations_url":"https://api.github.com/users/kmck/orgs","repos_url":"https://api.github.com/users/kmck/repos","events_url":"https://api.github.com/users/kmck/events{/privacy}","received_events_url":"https://api.github.com/users/kmck/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T02:12:36Z","updated_at":"2016-03-17T02:12:36Z","body":"Sure! So, without the use of the `engine` option, any references to `_` within templates use whatever `window._` is in the browser. If you're not already requiring lodash or underscore globally in your project, it might not be defined, so those `_.whatever` functions won't work. That's something that could happen if you do `<%- someVar %>`, which would normally try to use `_.escape`.\r\n\r\nIf you don't need `_.templateSettings.imports` and want to keep the bundled size down, you might not want to bother with the engine option in the first place. The idea is that `_.templateSettings.imports`, so being able to use the same thing to define imports for the templates is convenient.\r\n\r\nNow that I'm looking at it again, I could see how you might prefer to specify the object to use for imports without requiring the whole engine if you weren't already requiring it for your project. It's probably possible to [replace this](https://github.com/emaphp/underscore-template-loader/blob/master/index.js#L109) with something other than `_.templateSettings.imports`."}}