Skip to content

Commit

Permalink
fix(nextjs): Guard against injecting multiple times (#9807)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Dec 14, 2023
1 parent 9d4393d commit 8800d5b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ function addFilesToExistingEntryPoint(

if (typeof currentEntryPoint === 'string' || Array.isArray(currentEntryPoint)) {
newEntryPoint = arrayify(currentEntryPoint);
if (newEntryPoint.some(entry => filesToInsert.includes(entry))) {
return;
}

if (isDevMode) {
// Inserting at beginning breaks dev mode so we insert at the end
Expand All @@ -638,6 +641,9 @@ function addFilesToExistingEntryPoint(
else if (typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint) {
const currentImportValue = currentEntryPoint.import;
const newImportValue = arrayify(currentImportValue);
if (newImportValue.some(entry => filesToInsert.includes(entry))) {
return;
}

if (isDevMode) {
// Inserting at beginning breaks dev mode so we insert at the end
Expand Down

0 comments on commit 8800d5b

Please sign in to comment.