Repository navigation
feat: Add transpilePackages to configuration for Next.js - SFS-3100 - #3244
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughAdds an experimental Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
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. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/core/next.config.js (1)
12-15: ExtracttranspilePackagesListfor 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
📒 Files selected for processing (2)
packages/core/discovery.config.default.jspackages/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.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/core/discovery.config.default.js (1)
157-157:⚠️ Potential issue | 🟡 MinorFix the
transpilePackagesdoc 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 matchespackages/core/next.config.jswherelength > 0is 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
📒 Files selected for processing (2)
packages/core/discovery.config.default.jspackages/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>
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