Skip to content

Fix: Empty build.excludes or build.includes array breaks the build (fixes #3786)#3787

Open
swashbuck wants to merge 1 commit intomasterfrom
issue/3786
Open

Fix: Empty build.excludes or build.includes array breaks the build (fixes #3786)#3787
swashbuck wants to merge 1 commit intomasterfrom
issue/3786

Conversation

@swashbuck
Copy link
Copy Markdown
Contributor

Fixes #3786

Fix

  • Add .length checks to the includes, excludes, and productionExcludes guards in generateConfigData() so empty arrays are treated the same as undefined

Empty arrays are truthy in JavaScript, so if (buildConfig.excludes) passes for []. This propagates into generateExcludedRegExp() where [].map(...).join('|') produces an empty string, and new RegExp('', 'i') matches every file path - silently excluding all plugins.

Testing

  1. Set "build": { "excludes": [] } in config.json
  2. Run grunt build - verify the build completes normally (no applyDefaults error)
  3. Set "build": { "includes": [] } in config.json
  4. Run grunt build - verify the build completes normally
  5. Remove the build key entirely - verify the build still works (regression check)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Needs Reviewing

Development

Successfully merging this pull request may close these issues.

Fix: Empty build.excludes or build.includes array breaks the build

2 participants