Skip to content

Explicit packageFormat (or similar) claim for package.json recipes #3137

Description

@AMDphreak

Dub historically accepted package.json as a recipe filename (same name npm uses). Overlapping keys (name, version, dependencies) make heuristics brittle. Related work already refuses obvious npm files (#3118, #3136) and discusses deprecating the alias (#789).

Proposal

Beyond deny-lists of foreign keys: require (or strongly prefer) an explicit ecosystem claim when loading a file named package.json, for example:

{
  "packageFormat": "dub",
  "name": "my-pkg",
  "targetType": "library"
}

Suggested rules for Dub:

  1. Prefer dub.json / dub.sdl (already true).
  2. If the recipe file is named package.json and packageFormat is present:
    • "dub" → load as today
    • anything else → refuse with a clear error
  3. If packageFormat is absent on package.json: keep today's legacy/heuristic path for a deprecation window, then refuse or ignore (so bare unclaimed package.json stops being treated as Dub by default).

Exact field name is negotiable (packageFormat, ecosystem, etc.). The point is a positive claim, not only "looks like npm."

Cross-ecosystem ask

The same field only helps if JS tooling documents a matching claim ("packageFormat": "npm" or equivalent). Filing this with Dub and with the OpenJS Package Metadata Interoperability group so both sides can pick one key.

Motivation

Mixed monorepo: Antora/npm package.json at repo root, Dub recipe under app/dub.json. Root dub build misread the npm file until heuristics / a root dub.json intervened. An explicit claim would make that class of failure obvious and tool-agnostic.

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