Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(WellKnownErrorsPlugin): avoid compilation warnings array with emp…
…ty items (#57768) Currently, when a webpack compilation warning is processed by `WellKnownErrorsPlugin` and it's indeed a well know error that should be bypassed, the warning item is simply deleted from the array, which will produce an array with empty items: Example: ```js { client: { loading: false, totalModulesCount: 2172, errors: null, warnings: [ <1 empty item> ] }, server: { loading: false, totalModulesCount: 2119, errors: null, warnings: [ <1 empty item> ] }, edgeServer: { loading: false, totalModulesCount: 58, errors: null, warnings: null }, trigger: undefined, amp: {} } ``` This array with empty items generates a side effect on the [build output](https://github.com/vercel/next.js/blob/3553c6516d7a9aba98876f9660af0ee7c94dc2a3/packages/next/src/build/output/store.ts#L124), since the `warning` array has empty items: ``` ➤ npm run dev > next dev ▲ Next.js 14.0.1-canary.3 - Local: http://localhost:3000 - Environments: .env.development ✓ Ready in 2.6s ✓ Compiled /middleware in 109ms (58 modules) ○ Compiling /(dashboard)/page ... ⚠ ⚠ ``` ![CleanShot 2023-10-30 at 13 20 42@2x](https://github.com/vercel/next.js/assets/33168/fd25bc72-61d6-4446-83cb-87768d5135dd) This PR solves this issue by removing the `warning` item using the `Array.prototype.splice`, which removes the item instead of making the array position empty. Related PR: #57073 --------- Co-authored-by: Jimmy Lai <[email protected]>
- Loading branch information