Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Extension builds were failing with
ERROR in [entry] [initial] js/newtab.bundle.js Invalid array lengthafter commit 4d36738 which addedOpportunityEditRecruiterModal.Root Cause
The modal imports from
lib/schema/opportunity.ts, which contains complex zod validation schemas. When webpack processes this file during extension builds, Next.js 15.4.10's Babel plugin attempts to optimize/rewrite code patterns and hits a bug when processing:100_000_000,1_000_000)[0, 0.5, 1].map(item => z.literal(item, {...}))The Babel regex rewriting plugin creates an invalid internal array structure, causing the "Invalid array length" error.
Solution
Conditionally exclude opportunity-related modals from extension builds by checking
process.env.TARGET_BROWSERat compile time. These modals are webapp-only features (job posting management) and should never be loaded in the extension anyway.Why this approach:
process.env.*, enabling proper tree-shakingChanges
packages/shared/src/components/modals/common.tsx: WrappedOpportunityEditModalandOpportunityEditRecruiterModalin conditional checkspackages/shared/src/lib/schema/opportunity.ts: Minor optimization ofroleTypeunion (changed from.map()to explicit literals)Testing
Notes
This is a workaround for a Next.js 15.4.10 Babel bug. The issue may be resolved in future Next.js versions, but this approach has the added benefit of reducing extension bundle size by excluding webapp-only features.
Preview domain
https://hotfix-webpack-build.preview.app.daily.dev