marko
marko copied to clipboard
Proposal: Add support for marko.js for tag discovery
When overriding tags, it would be nice be able to be able to inherit from the marko.json
file.
Proposed Solution
Add support for a marko.js
file that will be used to resolve components. This can be used to override a marko.json
etc.
Overriding <await>
tag:
/marko/taglibs/async/marko.json
{
"<await>": {
"renderer": "./await-tag",
"@_var": "identifier",
"@_dataProvider": "expression",
"transformer": "./await-tag-transformer",
"@timeout": "integer",
...
...
...
}
}
/my-await/my-await-tag.js
module.exports = function (input, out) {
input.timeout = input.timeout || 20000;
...
};
/my-await/marko.js
const markoAwaitTag = require('marko/taglibs/async/marko.json');
const myAwaitProps = Object.assign({
renderer: './my-await-tag',
transformer: './my-await-transfomer'
// All other `<await>` properties should be inherited
}, markoAwaitTag['<await>']);
module.exports = {
'<my-await>': myAwaitProps
};
Another possible solution we discussed:
{
"<child-tag>": {
"extends": "/path/to/parent-tag/marko.json",
"renderer": "./child-tag"
}
}
Since we now recommend using TypeScript for much of the utility of that marko*.json
files provided I think adding a new feature like this is no longer needed.