cobalt-ui
cobalt-ui copied to clipboard
Add JSON output to plugin-js
The doc says:
pluginJS({
output: {
js: "index.js",
ts: "index.d.ts",
json: false, // set to a filename to generate JSON
},
}),
but the current @terrazzo/plugin-js (0.1.0) expects different configuration:
js({
js: "index.js",
// json: "tokens.json",
}),
Is the doc or the plugin out of date? I can create a pull request with edits.
Thanks for flagging! A bit of both.
ts - The new version dropped the ts option. It will just output .d.ts regardless of settings. There’s no reason you wouldn’t want this; it just improves interop invisibly (and if you don’t use TS, it’s just ignored). Further, there’s no reason you would ever name .d.ts differently than .js—that would just break TypeScript. So the API is just improved to be simpler here.
json - This is undone work I forgot about! We want to output a .json output that roughly matches the default JS output. Some questions that I’m not sure about, that the implementer can weigh in on:
- Since the
jsoutput exports a flat object of IDs → token values (with modes), should JSON do the same? jsjust discards a lot of the metadata from tokens (like$description). I got requests from people asking to not generate this, since they never used it. Is there any additional metadata we would want in thejsoutput?- If we include any metadata in
js, would JSON need any of that? (should it be a reserved namespace at the top?)
- If we include any metadata in
I’ve updated the issue name to better reflect the scope of work to be done. Would love a PR, whether that’s from you or anyone else reading this!