Skip to content
Snippets Groups Projects
Unverified Commit ba572b8f authored by Lauren Tan's avatar Lauren Tan
Browse files

Don't use loose mode in @babel/plugin-transform-spread

In
[`loose`](https://babeljs.io/docs/babel-plugin-transform-spread#loose)
mode, this plugin treats all iterables as arrays. This was causing
issues when compiling Zod (inlined into babel-plugin-react-compiler),
causing it to have a single element of `undefined: undefined` which
violates the zod schema

Note the spread below in Zod which was being transformed incorrectly:

```js
const pairs = [...ctx.data.entries()].map(([key2, value], index) => {
  return {
    key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, [index, "key"])),
    value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
  };
});
```
parent 2f4d2ee4
No related merge requests found
......@@ -19,7 +19,7 @@ module.exports = {
'@babel/plugin-transform-shorthand-properties',
'@babel/plugin-transform-computed-properties',
'@babel/plugin-transform-for-of',
['@babel/plugin-transform-spread', {loose: true, useBuiltIns: true}],
['@babel/plugin-transform-spread', {useBuiltIns: true}],
'@babel/plugin-transform-parameters',
['@babel/plugin-transform-destructuring', {loose: true, useBuiltIns: true}],
['@babel/plugin-transform-block-scoping', {throwIfClosureRequired: true}],
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment