Skip to content

Propose graph-aware preloading and Early Hints to rails/importmap-rails #45

Description

@mhenrixon

Split out of #21, which is otherwise complete.

The roadmap's "Upstream-first notes" say:

#19 (graph-aware preloading) and #20 (Early Hints) are not fork-specific; propose them to rails/importmap-rails after they land here so the next sync shrinks the diff. #14, #15, #16, #17, #18 lean on fork provenance or on behaviour upstream has declined.

Both have landed here and neither has been proposed upstream.

What to propose

Graph-aware preloading (#19) — config.importmap.preload_strategy = :reachable. Lives in lib/importmap/map.rb (preloaded_module_paths, ~l.282) and lib/importmap/graph.rb. Request path, no network, cached like the JSON. The motivating case is a real app that had to hand-write preload: false on apexcharts/core to stop shipping 1.1 MB on every page.

103 Early Hints (#20) — javascript_importmap_tags sends its modulepreload links as Early Hints. Lives in app/helpers/importmap/importmap_tags_helper.rb and lib/importmap/early_hints.rb, behind config.importmap.early_hints.

How

Per .claude/rules/upstream-sync.md → Contributing back: a clean branch off upstream/main, one PR each, opened against rails/importmap-rails. Whatever merges comes back through the next /upstream-sync and the fork's diff shrinks.

Note lib/importmap/graph.rb and lib/importmap/early_hints.rb are fork-only files, so each PR is close to additive upstream — but map.rb and the helper are upstream-owned here, and the upstream diff should be written against their current shape, not this fork's.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions