Skip to content

Images in versioned content are never resolved; versioned example build fails with missing 'images' export #155

Description

@rohilsurana

Problem

Two related symptoms, one root cause:

  1. chronicle build --config examples/versioned/chronicle.yaml fails on main:
[MISSING_EXPORT] Error: "images" is not exported by "examples/versioned/versions/v1/dev/index.mdx"
  1. Images referenced from versioned content (versions/v1/docs/*.mdx etc.) are never rewritten to /_content/ URLs, so image resolution, optimization, and cache versioning (fix: bust stale browser cache for replaced images via content-hash URLs #154) all skip them.

Root cause

remark-resolve-images finds the content root by searching the file path for the literal segment /content/:

const contentIdx = filePath.lastIndexOf('/content/')
if (contentIdx === -1) return

The .content mirror symlinks individual files, and Vite resolves those symlinks to their real paths. For latest content the real path happens to contain /content/ (e.g. examples/basic/content/docs/page.mdx), so it works. For versioned content the real path is examples/versioned/versions/v1/docs/page.mdx — no /content/ segment — so the plugin returns early and never sets file.data.images.

Because vite-config.ts uses valueToExport: ['readingTime', 'images'] and source.ts imports images from every globbed MDX module, the missing value becomes a hard build failure.

This also means any project whose content directory is not literally named content gets no image resolution at all.

Repro

bun run build:cli
./packages/chronicle/bin/chronicle.js build --config examples/versioned/chronicle.yaml
# 4x MISSING_EXPORT errors

Suggested fix

Stop inferring the content root from the path string. The plugin (or the MDX pipeline setup in vite-config.ts) already knows the real content roots from the chronicle config / .content mirror mapping, so pass them in as plugin options and match file paths against them. Always set file.data.images (even when empty) so the images export is guaranteed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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