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
generateConfigData and isPathIncluded implementation
Steps to reproduce
- Set
"build": { "excludes": [] } in config.json
- Run
grunt build or rub
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: [] - The generateExcludedRegExp function joins an empty array, producing new RegExp('', 'i') which matches every file path. All plugins are excluded, causing downstream errors like Cannot 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 truthy
Proposed fix
Add .length checks so empty arrays are treated identically to undefined:
if (buildConfig.includes?.length) ...
if (buildConfig.excludes?.length) ...
if (buildConfig.productionExcludes?.length) ...
Subject of the issue
Setting
build.excludesorbuild.includesto an empty array[]inconfig.jsoncauses 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
generateConfigDataandisPathIncludedimplementationSteps to reproduce
"build": { "excludes": [] }inconfig.jsongrunt buildorrubExpected behaviour
An empty
excludesarray excludes nothing. An emptyincludesarray 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.jsgenerateConfigData(), empty arrays pass the truthiness check and get propagated into grunt config:Proposed fix
Add
.lengthchecks so empty arrays are treated identically to undefined: