Skip to content

Read gatsby-config.mjs and gatsby-node.mjs in the Gatsby plugin - #2280

Merged
webpro merged 1 commit into
webpro-nl:mainfrom
SwastikTripathi:fix/gatsby-esm-config
Nov 2, 2026
Merged

webpro merged 1 commit into
webpro-nl:mainfrom
SwastikTripathi:fix/gatsby-esm-config

Conversation

@SwastikTripathi

@SwastikTripathi SwastikTripathi commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Gatsby reads gatsby-config.mjs and gatsby-node.mjs since 5.3 (ES Modules docs, and compile-gatsby-files.ts lists gatsby-node.mjs as a valid name). The Gatsby plugin only listed {js,jsx,ts,tsx}, so with .mjs config its plugins and setBabelPlugin calls were never read. Those plugins showed up as unused dependencies, and the src/pages entries weren't added.

The change adds mjs to the root gatsby-{config,node} pattern and to plugins/**/gatsby-node.

Verified with a new gatsby-config-mjs fixture and test, which fail without the change. All tests in test/plugins pass, and oxlint, oxfmt --check and tsc --noEmit are clean.

Written with Claude Code (AI). I read the Gatsby source and docs and ran the tests above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@2280
npm i https://pkg.pr.new/@knip/language-server@2280
npm i https://pkg.pr.new/@knip/mcp@2280

commit: ff21418

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! .mjs configs now give the same results as .js. One small correction for the description: the src/pages entries were already added before this change, because core falls back to the static production patterns when no config file is found. The visible symptom is that the .mjs config files are reported as unused.

@webpro
webpro merged commit daf7d03 into webpro-nl:main Nov 2, 2026
32 checks passed
@webpro

webpro commented Nov 3, 2026

Copy link
Copy Markdown
Member

πŸš€ This pull request is included in v6.44.2. See Release 6.44.2 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

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.

2 participants