Skip to content

Conversation

magistau
Copy link
Contributor

@magistau magistau commented Oct 4, 2025

This PR replaces --make-deps with two new flags:

  • --deps — where to write the list of dependencies
  • --deps-format — one of zero, json, make:
    • make: Makefile format, matches the behavior of --make-deps
      main.pdf: lib.typ /home/tau/.cache/typst/packages/preview/physica/0.9.6/physica.typ /home/tau/.cache/typst/packages/preview/physica/0.9.6/typst.toml main.typ image.png
    • json: JSON array of strings, each string being a (relative) path to a dependency
      ["lib.typ","/home/tau/.cache/typst/packages/preview/physica/0.9.6/physica.typ","/home/tau/.cache/typst/packages/preview/physica/0.9.6/typst.toml","main.typ","image.png"]
    • zero: sequence of strings delimited by a NUL byte
      lib.typ␀/home/tau/.cache/typst/packages/preview/physica/0.9.6/physica.typ␀/home/tau/.cache/typst/packages/preview/physica/0.9.6/typst.toml␀main.typ␀image.png␀
      

Comparison of formats:

Name Human-readable (-2..=+2) Machine-readable (-2..=+2) Allowed dependency paths
Makefile +1 -1 (largely unstandardized, essentially defined by an implementation — in fact, --make-deps was implemented by rewriting a part of GCC in Rust, and the GCC code says something like "well GNU Make does this; note that this still breaks sometimes") Valid Unicode without certain characters like $
JSON 0 (can be improved to +1 by using "pretty" option) +1 (standard is short and concise, easy to implement in any language, used by most utilities, but still requires stuff like escape processing) Valid Unicode
Zero/Null/text0 -0.5 (needs bat -A or similar) +2 (doesn't require any sort of escape parsing, can be parsed without copying) Anything without NUL (which AFAIK is forbidden on all existing systems)

Scale used:

  • (-2, +2) is Protobuf and similar (cannot be read by a human, close to a memory dump for a machine)
  • (0, 0) is something like XML (still can be read by a layperson and is well-defined, but is quite verbose and requires effort from both)
  • (+2, -2) is a free-form natural language description (the native tongue for humans, absolutely unreadable for machines, and even complicated NLP stuff is still imperfect)

Unresolved questions:

  • What should be the default --deps-format? Currently it's zero, because it's the only lossless one, but I admit it's not the most common format. Maybe use JSON as the middle ground?
  • Should JSON be minified?
  • What should be the name of the NUL-delimited format? It's too simple to have a standard (the only possible disagreement is whether the file should include a trailing NUL, but I haven't yet seen a tool not including one), so there's no standard name. I chose zero, because null can be confused for "lack of value", and text0 is a bit longer and includes combines letters and digits, which a part of my brain doesn't like for some reason.

(continuation of #6648)

@magistau magistau changed the title feat: --deps/--deps-format flags for getting a dependency list feat!: --deps/--deps-format flags for getting a dependency list Oct 4, 2025
@chekoopa
Copy link

chekoopa commented Oct 4, 2025

Shall the old option exist for some time as deprecated?

@laurmaedje
Copy link
Member

laurmaedje commented Oct 7, 2025

I wanted to include this in 0.14 since #6648 was being ignored for so long, but didn't have the time for review back and forth in time for the release, so I refactored this myself. In particular, I also readded the old option as deprecated.

Unfortunately, I could not push to the PR as usual (the relevant permission was disabled). If you want, you can push the commits I pushed to https://github.com/typst/typst/tree/deps-format to this PR and I'll merge later today. Otherwise, I'll have to create a new PR and close this one.


Regarding your unresolved questions, I made the following decisions.

What should be the default --deps-format? Currently it's zero, because it's the only lossless one, but I admit it's not the most common format. Maybe use JSON as the middle ground?

Yes, I prefer JSON.

Should JSON be minified?

I think minified is appropriate.

What should be the name of the NUL-delimited format?

Zero is fine.

@magistau
Copy link
Contributor Author

magistau commented Oct 7, 2025

Unfortunately, I could not push to the PR as usual (the relevant permission was disabled). If you want, you can push the commits I pushed to https://github.com/typst/typst/tree/deps-format to this PR and I'll merge later today.

Fixed

@laurmaedje laurmaedje changed the title feat!: --deps/--deps-format flags for getting a dependency list Add --deps and --deps-format flags for emitting a dependency list Oct 7, 2025
@laurmaedje laurmaedje added this pull request to the merge queue Oct 7, 2025
@laurmaedje
Copy link
Member

laurmaedje commented Oct 7, 2025

Thanks! Also for the patience with all of this. I'm now quite happy with the final result.

Merged via the queue into typst:main with commit 8e69243 Oct 7, 2025
16 checks passed
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.

3 participants