Skip to content

[core] yarn build omits packages from metadata.json in Next.js Pages Router - #646

Merged
illiakovalenko merged 3 commits into
devfrom
JSS-10270-yarn-build-package-omit-fix
Oct 7, 2026
Merged

illiakovalenko merged 3 commits into
devfrom
JSS-10270-yarn-build-package-omit-fix

Conversation

@sc-naveenhedallaarachchi

@sc-naveenhedallaarachchi sc-naveenhedallaarachchi commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description / Motivation

  • Add @sitecore-content-sdk/personalize to the Next.js Pages Router template dependencies, matching the App Router templates.
  • Yarn does not install this peer on its own, so yarn build could not resolve it and .sitecore/metadata.json omitted it.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@changeset-bot

changeset-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c27e94c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-content-sdk-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 69.05 KB 69.05 KB ✅ 0.00 KB 97.44% 97.44% 0.00%
angular 438.39 KB 438.39 KB ✅ 0.00 KB 94.22% 94.22% 0.00%
cli 84.63 KB 84.63 KB ✅ 0.00 KB 77.84% 77.84% 0.00%
content 525.88 KB 525.88 KB ✅ 0.00 KB 93.10% 93.10% 0.00%
core 139.38 KB 139.38 KB ✅ 0.00 KB 91.80% 91.80% 0.00%
create-content-sdk-app 551.33 KB 551.42 KB 🔺 +0.09 KB 96.47% 96.47% 0.00%
events 72.33 KB 72.33 KB ✅ 0.00 KB 97.97% 97.97% 0.00%
nextjs 585.07 KB 585.07 KB ✅ 0.00 KB 91.79% 91.79% 0.00%
personalize 64.01 KB 64.01 KB ✅ 0.00 KB 99.74% 99.74% 0.00%
react 254.44 KB 254.44 KB ✅ 0.00 KB 93.83% 93.83% 0.00%
search 16.69 KB 16.69 KB ✅ 0.00 KB 98.89% 98.89% 0.00%
Total — — 🔺 +0.09 KB — — —

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this treats the symptom rather than the cause.

metadata.json is missing @sitecore-content-sdk/personalize on a Yarn Pages Router app because the package is not installed: nextjs imports it in for exmaple proxy/personalize-proxy.js but only declares it as a peer, the Pages Router template does not list it, and Yarn does not install missing peers. With this PR, yarn build still fails:

Module not found: Can't resolve '@sitecore-content-sdk/personalize'

and metadata.json would list a package that is not in node_modules or the lockfile.

Add @sitecore-content-sdk/personalize to the Pages Router template's dependencies, as the App Router template already does. I tried it on a scaffolded app with Yarn 1.22.22 yarn build passes and metadata.json contains personalize at 2.1.0, so the metadata.ts changes can be dropped.

If the peer lookup stays, it has a few problems: the version comes from the registry rather than the install, every build makes blocking network calls (20s timeout per missing peer), registry auth and proxy config are ignored, and only process.cwd()/node_modules is checked, which misses hoisted and pnpm installs.

@illiakovalenko
illiakovalenko merged commit 16c65a2 into dev Oct 7, 2026
5 checks passed
@illiakovalenko
illiakovalenko deleted the JSS-10270-yarn-build-package-omit-fix branch October 7, 2026 07:58
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