-
Notifications
You must be signed in to change notification settings - Fork 251
Fix: Empty build.excludes or build.includes array breaks the build #3786
Copy link
Copy link
Labels
Description
Subject of the issue
Setting build.excludes or build.includes to an empty array [] in config.json causes unexpected build failures. An empty array should be equivalent to not specifying the property at all, but instead it silently breaks plugin filtering.
Your environment
- Affects all framework versions with the current
generateConfigDataandisPathIncludedimplementation
Steps to reproduce
- Set
"build": { "excludes": [] }inconfig.json - Run
grunt buildorrub
Expected behaviour
An empty excludes array excludes nothing. An empty includes array has no filtering effect. Both should behave identically to not specifying the property.
Actual behaviour
excludes: []- ThegenerateExcludedRegExpfunction joins an empty array, producingnew RegExp('', 'i')which matches every file path. All plugins are excluded, causing downstream errors likeCannot read properties of undefined (reading 'applyDefaults').includes: []- Similarly produces a malformed regex with a trailing|alternative that matches everything.
Root cause
In helpers.js generateConfigData(), empty arrays pass the truthiness check and get propagated into grunt config:
if (buildConfig.includes) data.includes = ... // [] is truthy
if (buildConfig.excludes) data.excludes = ... // [] is truthyProposed fix
Add .length checks so empty arrays are treated identically to undefined:
if (buildConfig.includes?.length) ...
if (buildConfig.excludes?.length) ...
if (buildConfig.productionExcludes?.length) ...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Needs Reviewing