Skip to content

Deterministic mdz create output (honor SOURCE_DATE_EPOCH) #2

Description

@kylemwhite

Make mdz create output deterministic (honor SOURCE_DATE_EPOCH)

Problem

mdz create stamps the wall clock into the archive, so re-running it on unchanged sources produces a byte-different .mdz every time:

  • manifest created/modified timestamps (new Date().toISOString())
  • zip entry modification dates (DOS date/time from new Date(), which also depends on the local timezone)

For consumers that commit generated .mdz (e.g. mdzip.org commits assets/docs/*.mdz, built via the CLI in build:mdz), every build dirties the tree with byte-only diffs even when nothing changed.

Request

Support reproducible builds by pinning the clock when requested:

  • Honor the SOURCE_DATE_EPOCH environment variable (seconds since epoch — the de-facto reproducible-builds standard) for both the manifest timestamps and the zip entry dates.
  • Optionally a --source-date/--mtime flag as an explicit equivalent.
  • Use UTC for the zip DOS date derivation so output doesn't vary by timezone.

When set, two runs over identical inputs should produce byte-identical archives.

Reference

@mdzip/core-js's MdzPackagerCore.buildArchive has the same wall-clock behavior and no override. mdzip.org worked around it for its in-process sample builds by pinning globalThis.Date + TZ=UTC in scripts/build-samples.mjs, but that trick can't reach the CLI (it's a separate process), so build:mdz archives remain non-deterministic. A SOURCE_DATE_EPOCH-aware CLI (ideally backed by a timestamp option in core-js's packager) is the proper fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions