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:
- Prefer
dub.json / dub.sdl (already true).
- If the recipe file is named
package.json and packageFormat is present:
"dub" → load as today
- anything else → refuse with a clear error
- 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.
Dub historically accepted
package.jsonas 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:
dub.json/dub.sdl(already true).package.jsonandpackageFormatis present:"dub"→ load as todaypackageFormatis absent onpackage.json: keep today's legacy/heuristic path for a deprecation window, then refuse or ignore (so bare unclaimedpackage.jsonstops 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.jsonat repo root, Dub recipe underapp/dub.json. Rootdub buildmisread the npm file until heuristics / a rootdub.jsonintervened. An explicit claim would make that class of failure obvious and tool-agnostic.