Skip to content

Conversation

@dwego
Copy link

@dwego dwego commented Nov 6, 2025

Summary

This PR fixes the CLI build environment for ESM (.mjs) output and adds the new --time flag to measure encode/decode execution time.


Changes

  • Fixed import path in bin/toon.mjs to use ../dist/index.mjs

  • Updated dev entrypoint to run from cli-entry.ts

  • Added new --time flag:

    toon --encode input.json --output output.toon --time

    Output example:

    ✔ Encoded `input.json` → `output.toon`
    ┌────────────────────────────┐
    │ Encode time: 0.153s        │
    └────────────────────────────┘
    
  • Updated CLI documentation to include the --time option


Why

Previous CLI builds failed in ESM mode due to .js import mismatch
The --time flag helps benchmark encoding/decoding performance
Improves overall developer experience and aligns with the TOON principles of token efficiency and simplicity


Testing

npm run dev -- --encode input.json --output output.toon --time
toon --encode input.json --output output.toon --time
Verified outputs for both encode and decode modes

@dwego dwego force-pushed the fix/cli-esm-and-time-flag branch from 4319a2c to 6b14295 Compare November 6, 2025 19:06
@johannschopplich
Copy link
Collaborator

Thanks a lot! Some thoughts:

  • Actually, tsdown builds an index.js. That's why we have to import it.
  • I like the idea of the time flag, but honestly, the encoding duration is negligible.

Appreciate your work, but I have do deny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants