Skip to content

feat: Add transpilePackages to configuration for Next.js - SFS-3100 - #3244

Merged
eduardoformiga merged 3 commits into
devfrom
feat/transpile-packages
Mar 23, 2026
Merged

eduardoformiga merged 3 commits into
devfrom
feat/transpile-packages

Conversation

@eduardoformiga

@eduardoformiga eduardoformiga commented Mar 18, 2026 •

Copy link
Copy Markdown
Member

What's the purpose of this pull request?

This update introduces a new configuration option, transpilePackages, to the discovery configuration. It allows specifying which package names to transpile, enhancing compatibility with Next.js's transpilePackages feature. The change is reflected in both the discovery and Next.js configuration files.

References

https://nextjs.org/docs/app/api-reference/config/next-config-js/transpilePackages

Summary by CodeRabbit

  • New Features
    • Added an experimental configuration option to list packages to be transpiled, defaulting to an empty list.
    • Runtime configuration now respects this experimental setting and will include a transpile entry when the list is populated, allowing builds to adapt when the option is used.

This update introduces a new configuration option, `transpilePackagesList`, to the discovery configuration. It allows specifying package names to be transpiled, enhancing compatibility with Next.js's transpilePackages feature. The change is reflected in both the discovery and Next.js configuration files.
@coderabbitai

coderabbitai Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f74326c-7e8c-49cc-8fad-def93e666dc3

📥 Commits

Reviewing files that changed from the base of the PR and between 4371c3b and 7a0cac7.

📒 Files selected for processing (1)
  • packages/core/discovery.config.default.js
✅ Files skipped from review due to trivial changes (1)
  • packages/core/discovery.config.default.js

Walkthrough

Adds an experimental transpilePackages array (default []) to discovery defaults and conditionally injects transpilePackages into the exported Next.js config when the array is non-empty. No other runtime logic was altered.

Changes

Cohort / File(s) Summary
Discovery default config
packages/core/discovery.config.default.js
Added experimental.transpilePackages: [] with an inline comment describing its expected use for listing package names to transpile.
Next.js configuration
packages/core/next.config.js
Conditionally spreads transpilePackages into the exported Next.js config when storeConfig.experimental.transpilePackages is a non-empty array.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • hellofanny
  • gabpaladino
  • renatamottam

Poem

A tiny list waits in the dark,
Empty now, but ready to spark.
When packages need a smoother ride,
The config opens, arms stretched wide. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding transpilePackages to configuration for Next.js, which matches the file modifications and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/transpile-packages

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codesandbox-ci

codesandbox-ci Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@eduardoformiga
eduardoformiga marked this pull request as ready for review March 18, 2026 22:58
@eduardoformiga
eduardoformiga requested a review from a team as a code owner March 18, 2026 22:58
@eduardoformiga
eduardoformiga requested review from hellofanny and lariciamota and removed request for a team March 18, 2026 22:58
@eduardoformiga eduardoformiga changed the title feat: Add transpilePackagesList to configuration for Next.js feat: Add transpilePackagesList to configuration for Next.js - SFS-3100 Mar 18, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/core/next.config.js (1)

12-15: Extract transpilePackagesList for improved readability and robustness.

Current logic is correct, but extracting the normalized list upfront avoids repeated property access and centralizes any defensive validation (dedup, trim, type-check).

♻️ Suggested refactor
+const transpilePackagesList = [
+  ...new Set(
+    (storeConfig.experimental?.transpilePackagesList ?? [])
+      .filter((pkg) => typeof pkg === 'string')
+      .map((pkg) => pkg.trim())
+      .filter(Boolean)
+  ),
+]
+
 const nextConfig = {
   /* config options here */
   /* Replaces terser by swc for minifying. It's the default in NextJS 13 */
   swcMinify: true,
-  ...(Array.isArray(storeConfig.experimental?.transpilePackagesList) &&
-    storeConfig.experimental.transpilePackagesList.length > 0 && {
-      transpilePackages: storeConfig.experimental.transpilePackagesList,
-    }),
+  ...(transpilePackagesList.length > 0 && {
+    transpilePackages: transpilePackagesList,
+  }),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/next.config.js` around lines 12 - 15, Extract and normalize
storeConfig.experimental?.transpilePackagesList into a local constant (e.g.,
transpilePackagesList) before the spread expression, validate it's an array,
map/trim entries, remove duplicates, and only pass it to the transpilePackages
property when non-empty; update the spread that currently references
storeConfig.experimental?.transpilePackagesList to use this normalized
transpilePackagesList so the logic in transpilePackages is clearer and robust.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/core/discovery.config.default.js`:
- Line 157: The doc comment for transpilePackagesList is misleading and has a
typo; update the comment for the transpilePackagesList setting to fix the typo
and explicitly state that only a non-empty array enables Next.js package
transpilation (e.g., "Package names to transpile (e.g. ['@vtex/components']).
Only a non-empty list enables Next.js transpilePackages; an empty list disables
it."). Modify the comment adjacent to the transpilePackagesList declaration to
use that wording and remove "Usempty" ambiguity.

---

Nitpick comments:
In `@packages/core/next.config.js`:
- Around line 12-15: Extract and normalize
storeConfig.experimental?.transpilePackagesList into a local constant (e.g.,
transpilePackagesList) before the spread expression, validate it's an array,
map/trim entries, remove duplicates, and only pass it to the transpilePackages
property when non-empty; update the spread that currently references
storeConfig.experimental?.transpilePackagesList to use this normalized
transpilePackagesList so the logic in transpilePackages is clearer and robust.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15d3f3ef-9312-4d8d-96f2-23aff5b02e6d

📥 Commits

Reviewing files that changed from the base of the PR and between c6e0f65 and 30bbd0b.

📒 Files selected for processing (2)
  • packages/core/discovery.config.default.js
  • packages/core/next.config.js

This change updates the configuration files to replace the deprecated `transpilePackagesList` with `transpilePackages`, ensuring consistency and compatibility with Next.js's transpilePackages feature.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
packages/core/discovery.config.default.js (1)

157-157: ⚠️ Potential issue | 🟡 Minor

Fix the transpilePackages doc comment typo and condition wording.

Line 157 has a typo (Usempty) and currently reads ambiguously. It should explicitly state that only a non-empty array enables Next.js transpilation (which matches packages/core/next.config.js where length > 0 is required).

✍️ Suggested update
-    /** Package names to transpile (e.g. ['@vtex/components']). Usempty, enables Next.js transpilePackages. */
+    /** Package names to transpile (e.g. ['@vtex/components']). Only a non-empty list enables Next.js transpilePackages. */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/discovery.config.default.js` at line 157, Doc comment for
transpilePackages contains a typo and ambiguous wording; update the comment for
the transpilePackages configuration to fix "Usempty" and make it clear that only
a non-empty array enables Next.js transpilation (matching the actual check that
uses length > 0 in packages/core/next.config.js). Locate the transpilePackages
variable/doc comment and replace the sentence so it reads something like:
"Package names to transpile (e.g. ['@vtex/components']). Only a non-empty array
enables Next.js transpilePackages." Ensure the wording explicitly references the
non-empty array requirement.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/core/discovery.config.default.js`:
- Line 157: Doc comment for transpilePackages contains a typo and ambiguous
wording; update the comment for the transpilePackages configuration to fix
"Usempty" and make it clear that only a non-empty array enables Next.js
transpilation (matching the actual check that uses length > 0 in
packages/core/next.config.js). Locate the transpilePackages variable/doc comment
and replace the sentence so it reads something like: "Package names to transpile
(e.g. ['@vtex/components']). Only a non-empty array enables Next.js
transpilePackages." Ensure the wording explicitly references the non-empty array
requirement.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 37a3bb48-1b8c-40bf-b5ae-6573b560ab09

📥 Commits

Reviewing files that changed from the base of the PR and between 30bbd0b and 4371c3b.

📒 Files selected for processing (2)
  • packages/core/discovery.config.default.js
  • packages/core/next.config.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/next.config.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@eduardoformiga eduardoformiga changed the title feat: Add transpilePackagesList to configuration for Next.js - SFS-3100 feat: Add transpilePackages to configuration for Next.js - SFS-3100 Mar 23, 2026
@eduardoformiga
eduardoformiga merged commit 9399323 into dev Mar 23, 2026
5 checks passed
@eduardoformiga
eduardoformiga deleted the feat/transpile-packages branch March 23, 2026 16:23
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