Skip to content
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

Add JSON output to plugin-js #346

Open
gynekolog opened this issue Nov 12, 2024 · 1 comment
Open

Add JSON output to plugin-js #346

gynekolog opened this issue Nov 12, 2024 · 1 comment
Labels
good first issue Good for newcomers help wanted PRs are welcome! p2 Medium priority plugin-js @terrazzo/plugin-js

Comments

@gynekolog
Copy link

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",
    }),

image

Is the doc or the plugin out of date?
I can create a pull request with edits.

@drwpow drwpow added help wanted PRs are welcome! good first issue Good for newcomers plugin-js @terrazzo/plugin-js labels Nov 13, 2024
@drwpow drwpow changed the title Outdated @terrazzo/plugin-js doc Add JSON output to plugin-js Nov 13, 2024
@drwpow drwpow added the p2 Medium priority label Nov 13, 2024
@drwpow
Copy link
Collaborator

drwpow commented Nov 13, 2024

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 js output exports a flat object of IDs → token values (with modes), should JSON do the same?
  • js just 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 the js output?
    • If we include any metadata in js, would JSON need any of that? (should it be a reserved namespace at the top?)

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted PRs are welcome! p2 Medium priority plugin-js @terrazzo/plugin-js
Projects
None yet
Development

No branches or pull requests

2 participants