-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: add main
property, or empty index.js
#5
Comments
Having hacked away at a few things for a while I managed to discover that
worked ok. However, it would be nice if the location of the template was defiend in the "main" property in package.json anyway just to make it a little easier to find, and more robust of the file structure were liable to change in future. Thanks. |
@alexmuller @easternbloc could you feed into this? It sounds like Lenny's request is associated with conventions around usage of |
Thanks @tombye I had a few discussions on this topic on #nodejs irc channel, and general consensus was that "this is weird because it's not a node module and you'd never Generally speaking though, the |
@lennym IMHO I think it should point at the |
@easternbloc - I think you mean https://github.com/alphagov/govuk_template, but sure... |
^^ that |
It is useful when building modules which depend on the templates to be able to programmatically obtain the location of the template, especially so when installing as an npm package, as the install location may be dependent on other factors. Setting the "main" property of the package.json allows the full path of the tempalte to be ascertained using `require.resolve('govuk_template_*')` in a node environment. See alphagov/govuk_template_mustache#5
I'm trying to build some modules which depend on this, but since it can't be found with
require.resolve()
as it has no canonical file it's proving quite difficult to reliably resolve the install location to dofs.readFile
etc on it. Looking in ./node_modules works in most cases, but not if the parent project already has this as a dependency.Either adding a
main
property in the package.json to point to the template file (ideal scenario for me), or adding a blank (or maybe log a usage warning) index.js file in the root will allowrequire.resolve('govuk_template_mustache');
to successfully resolve the install location, and so make it easier to build other modules which sit on top of this without needing additional caveats.The text was updated successfully, but these errors were encountered: