Closed gobwas closed 9 years ago
This issue should not be closed since dm.js still doesn't support injecting a module like a single structure. Since issue#36 already has a feature to refer module properties using JSON, why don't we use same syntax to inject the whole exported object. For example:
//module.js
module.exports = { /* ... */ };
//app.js
var config = {
"module": {
"path": "./module#"
}
}
Since #
is used as a separator between module path and JSON Pointer syntax, an empty string that follows after #
says that we need to select the whole JSON document.
But this logic must already work :) did you tried it?
Aw, I understand, at now path is a path to the constructor. The question is why u want to configure simple object/function like service definition?
No it doesn't. In my test project it didn't work, I can't remember why, I'll put some details later.
To add some flexibility to use modules. There can be a situation in which you may want to use a plain object containing a bunch of function. Something like a Singleton. Also, you may want to export a single function which should be used without new
keyword as factories or as strategies. Do the main point is not to limit users with constructors.
{ "calls": ["<./path/to/module.js>"] }