marko icon indicating copy to clipboard operation
marko copied to clipboard

Proposal: Add support for marko.js for tag discovery

Open austinkelleher opened this issue 7 years ago • 1 comments

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
};

austinkelleher avatar May 05 '17 19:05 austinkelleher

Another possible solution we discussed:

{
  "<child-tag>": {
    "extends": "/path/to/parent-tag/marko.json",
    "renderer": "./child-tag"
  }
}

austinkelleher avatar May 09 '17 12:05 austinkelleher

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.

DylanPiercey avatar May 23 '23 16:05 DylanPiercey