Skip to content

feat(config): allow other .json files when explicitly set #333

@kopach

Description

@kopach

Description

Problem

syncpack currently only picks up files named package.json, even when source contains explicit patterns for other filenames.

Minimal Reproduction

Repo structure

.
├─ package.json
└─ packages/
   └─ lib-a/
      ├─ package.json
      └─ package.public.json

syncpack config

{
  "source": [
    "package.json",
    "packages/*/package.json",
    "packages/*/package.public.json"
  ],
  "semverGroups": [
    {
      "dependencies": ["**"],
      "range": ""
    }
  ]
}

packages/lib-a/package.public.json

{
  "name": "lib-a-public",
  "version": "1.0.0",
  "dependencies": {
    "react": "^18.2.0"
  }
}

Run

syncpack lint

Actual result

packages/lib-a/package.public.json is ignored (dependencies inside it are not checked).

Expected result

packages/lib-a/package.public.json is treated as a source file because it is explicitly listed in source.


Why this matters

In my monorepos setup, a package need:

  • package.json for internal workspace/tooling behavior
  • package.public.json for the published manifest (or prepublish transform source)

Workaround

It's possible to create a separate folder containing package.jcon (e.g. public/package.json), but this creates extra issues:

  • Must be excluded from workspace discovery (pnpm, nx, etc.)
  • Tooling may accidentally treat it as another workspace package

Allowing custom manifest filenames directly in source would avoid those conflicts and better support real-world publish workflows.

Suggested Solution

Allow custom package.json names when path contains file name e.g.

{
  "source": [
    "package.json",
    "packages/*", // << directory, no change
    "packages/*/package.public.json" // <<< exact file name
  ],

Optional comments

I'm happy to help to resolve this issue by contributing to project. The source code to change, from what I can tell is here

pub fn normalise_pattern(mut pattern: String) -> String {
let negated = pattern.starts_with('!');
if negated {
pattern.remove(0);
}
let normalized = pattern.replace('\\', "/");
if negated {
if normalized.contains("package.json") {
format!("!{normalized}")
} else {
format!("!{normalized}/package.json")
}
} else if normalized.contains("package.json") {
normalized
} else {
format!("{normalized}/package.json")
}

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions