Skip to content

Commit 8800d5b

Browse files
authored
fix(nextjs): Guard against injecting multiple times (#9807)
1 parent 9d4393d commit 8800d5b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/nextjs/src/config/webpack.ts

+6
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ function addFilesToExistingEntryPoint(
625625

626626
if (typeof currentEntryPoint === 'string' || Array.isArray(currentEntryPoint)) {
627627
newEntryPoint = arrayify(currentEntryPoint);
628+
if (newEntryPoint.some(entry => filesToInsert.includes(entry))) {
629+
return;
630+
}
628631

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

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

0 commit comments

Comments
 (0)