mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(package): exclude transform-spread from babel preset-env to preserve native spread behavior (#66363)
This commit is contained in:
+1
-1
@@ -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]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user