Skip to content

Refuse to load npm package.json files - #3136

Open
AMDphreak wants to merge 2 commits into
dlang:masterfrom
AMDphreak:fix/3118-refuse-npm-package-json
Open

Refuse to load npm package.json files#3136
AMDphreak wants to merge 2 commits into
dlang:masterfrom
AMDphreak:fix/3118-refuse-npm-package-json

Conversation

@AMDphreak

Copy link
Copy Markdown

Summary

  • Refuse to parse a file named package.json when it contains npm-only top-level keys (packageManager, scripts, devDependencies, workspaces, private), matching the proposal in Refuse to load npm package.json files #3118.
  • Keep loading legacy Dub recipes that still use the package.json filename (no npm sentinel keys).
  • Add unit tests, an integration .fail_build case, and a changelog entry.

Test plan

  • CI unit tests for source/dub/recipe/io.d (npm refuse + legacy allow)
  • CI integration: test/issue3118-npm-package-json fails to build as expected
  • CI integration: test/1-exec-simple-package-json still builds
  • Manual: in a repo with only an npm package.json, dub build prints a clear refusal instead of unknown-key warnings

Fixes #3118

AMDphreak and others added 2 commits July 24, 2026 19:46
When Dub finds a package.json with npm-only top-level keys
(packageManager, scripts, devDependencies, workspaces, private),
raise a hard error instead of parsing it as a Dub recipe.

Fixes dlang#3118

Co-authored-by: Cursor <cursoragent@cursor.com>
Force-track package.json under test/ (gitignore only allowlists dub.json)
and allowlist package.json test fixtures going forward.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown

Thanks for your Pull Request and making D better!

This comment will automatically be updated to summarize some statistics in a few minutes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refuse to load npm package.json files

1 participant