{"action":"created","issue":{"url":"https://api.github.com/repos/at0g/nunjucks-loader/issues/3","labels_url":"https://api.github.com/repos/at0g/nunjucks-loader/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/at0g/nunjucks-loader/issues/3/comments","events_url":"https://api.github.com/repos/at0g/nunjucks-loader/issues/3/events","html_url":"https://github.com/at0g/nunjucks-loader/issues/3","id":72872354,"number":3,"title":"I need to use to be able to resolve my modules and webpack node_modules in the loader","user":{"login":"dschissler","id":3968727,"avatar_url":"https://avatars.githubusercontent.com/u/3968727?v=3","gravatar_id":"","url":"https://api.github.com/users/dschissler","html_url":"https://github.com/dschissler","followers_url":"https://api.github.com/users/dschissler/followers","following_url":"https://api.github.com/users/dschissler/following{/other_user}","gists_url":"https://api.github.com/users/dschissler/gists{/gist_id}","starred_url":"https://api.github.com/users/dschissler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschissler/subscriptions","organizations_url":"https://api.github.com/users/dschissler/orgs","repos_url":"https://api.github.com/users/dschissler/repos","events_url":"https://api.github.com/users/dschissler/events{/privacy}","received_events_url":"https://api.github.com/users/dschissler/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-03T21:59:46Z","updated_at":"2015-05-04T00:32:08Z","closed_at":null,"body":"I am unable to configure nunjucks-loader to use my app modules.  I have a module called locale that does some fancy async downloading of the correct locale and I am unable to configure the loader to be able to access these in a global function.\r\n\r\nBelow the locale module is a custom one.\r\n\r\n**nunjucks.config.coffee**\r\n\r\n```coffeescript\r\n'use strict'\r\n\r\nlocale = require 'locale'\r\n\r\n# I added this to see if node modules can be found\r\nrequire 'path'\r\n\r\nmodule.exports = (env) ->\r\n\r\n  env.addGlobal 'gettext', (message) -> locale.gettext message\r\n  env.addGlobal 't', (message) -> locale.gettext message\r\n  env.addGlobal 'ngettext', (msg1, msg2, n) -> locale.ngettext msg1, msg2, n\r\n  env.addGlobal 'n', (msg1, msg2, n) -> locale.ngettext msg1, msg2, n\r\n\r\n  null\r\n```\r\n\r\n**webpack.config.coffee**\r\n```coffeescript\r\n  resolveLoader:\r\n    root: nodeModulesRoot\r\n    modulesDirectories: [appModulesRoot, nodeModulesRoot, bowerRoot]\r\n```\r\n\r\nIt is complaining with the following.  'jed' is a translation library in the bowerRoot.\r\n\r\n```\r\nERROR in ../app/webpack/entries/app.site/partials/layout.nunj\r\nModule build failed: Error: Cannot find module 'jed'\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/at0g/nunjucks-loader/issues/comments/98560265","html_url":"https://github.com/at0g/nunjucks-loader/issues/3#issuecomment-98560265","issue_url":"https://api.github.com/repos/at0g/nunjucks-loader/issues/3","id":98560265,"user":{"login":"at0g","id":1406770,"avatar_url":"https://avatars.githubusercontent.com/u/1406770?v=3","gravatar_id":"","url":"https://api.github.com/users/at0g","html_url":"https://github.com/at0g","followers_url":"https://api.github.com/users/at0g/followers","following_url":"https://api.github.com/users/at0g/following{/other_user}","gists_url":"https://api.github.com/users/at0g/gists{/gist_id}","starred_url":"https://api.github.com/users/at0g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/at0g/subscriptions","organizations_url":"https://api.github.com/users/at0g/orgs","repos_url":"https://api.github.com/users/at0g/repos","events_url":"https://api.github.com/users/at0g/events{/privacy}","received_events_url":"https://api.github.com/users/at0g/received_events","type":"User","site_admin":false},"created_at":"2015-05-04T00:32:08Z","updated_at":"2015-05-04T00:32:08Z","body":"My understanding is that `addGlobal` is for adding simple values - the nunjucks docs make no mention of a third parameter when calling `addGlobal`, so it's probably not suitable for returning an async result.\r\n\r\nIn the `nunjucks.config.coffee` example, your globals are functions that expect input rather than just being values. Have you tried changing the `env.addGlobal` lines to `env.addFilter`? `addFilter` will work with async values if passed true as a third parameter."}}