fix(package): exclude transform-spread from babel preset-env to preserve native spread behavior (#66363)

This commit is contained in:
Jeevankumar S
2026-03-11 17:14:13 +05:30
committed by GitHub
parent f10df73594
commit 5b9c2516a4
2 changed files with 3 additions and 3 deletions
@@ -54,7 +54,7 @@ const exports = {};
const a = eval(script);
const shoppingListString = exports.ShoppingList.toString();
assert.match(shoppingListString, /var\s*toggleItem\s*=\s*useCallback\s*\(\s*function\s*\(\s*item\s*\)\s*{\s*(return)?\s+setSelectedItems\s*\(\s*function\s*\(prev\)\s*{\s*return\s+prev\.includes\(item\)\s*\?\s*prev\.filter\(function\s*\(i\)\s*\{\s*return\s+i\s!==\sitem;\s*\}\s*\)\s*:\s*\[\].concat\(_toConsumableArray\(prev\),\s+\[item\]\);\s*}\);?/);
assert.match(shoppingListString, /var\s*toggleItem\s*=\s*useCallback\s*\(\s*function\s*\(\s*item\s*\)\s*{\s*(return)?\s+setSelectedItems\s*\(\s*function\s*\(prev\)\s*{\s*return\s+prev\.includes\(item\)\s*\?\s*prev\.filter\(function\s*\(i\)\s*\{\s*return\s+i\s!==\sitem;\s*\}\s*\)\s*:\s*\[\.\.\.prev,\s*item\];\s*}\);?/);
```
You should add `setSelectedItems` as the only dependency in the dependencies array.
@@ -69,7 +69,7 @@ async function loadPresetEnv() {
);
presetsJS = {
presets: [presetEnv]
presets: [[presetEnv, { exclude: ['transform-spread'] }]]
};
}
@@ -84,7 +84,7 @@ async function loadPresetReact() {
);
presetsJSX = {
presets: [presetEnv, presetReact]
presets: [[presetEnv, { exclude: ['transform-spread'] }], presetReact]
};
}