Skip to content

Commit 57755e5

Browse files
authored
fix: remove extra class-props babel plugin (#363)
The`@babel/plugin-proposal-class-properties` no longer needs to be explicitly added, as it is now incorporated into `@babel/preset-env`. You can see this in a freshly generated RN library by adding `debug: true` to this default configuration: ``` % yarn bob build yarn run v1.22.19 $ .../rnlib/node_modules/.bin/bob build ℹ Building target commonjs ℹ Cleaning up previous build at lib/commonjs ℹ Compiling 1 files in src with babel @babel/preset-env: `DEBUG` option Using targets: { "chrome": "108", "edge": "108", "firefox": "108", "ios": "15.6", "node": "16", "safari": "15.6", "samsung": "19" } Using modules transform: commonjs Using plugins: proposal-class-static-block { ios, node < 16.11, safari } proposal-private-property-in-object { node < 16.9 } syntax-class-properties <---- syntax-numeric-separator syntax-nullish-coalescing-operator proposal-optional-chaining { node < 16.9 } syntax-json-strings syntax-optional-catch-binding transform-parameters { ios, safari } syntax-async-generators syntax-object-rest-spread proposal-export-namespace-from { ios, safari } transform-modules-commonjs proposal-dynamic-import ... ``` Removing this duplicate entry ensures the optimal application of transforms within the preset-env space. This was discovered while attempting to update `react-native-svg`, which has a pathologic case in their `Symbol.tsx` that causes a babel parser error that is resolved when this entry is removed: ``` Error: .../react-native-svg/src/elements/Symbol.tsx: We don't know what to do with this node type. We were previously a Statement but we can't fit in here? at NodePath.insertBefore (.../react-native-svg/node_modules/@babel/traverse/lib/path/modification.js:57:11) ... at async.call.result.err.err (.../react-native-svg/node_modules/gensync/index.js:223:11) { code: 'BABEL_TRANSFORM_ERROR' ``` ### Test plan I reproduced the minimal problem space at https://github.com/merrywhether/rnlib, and also verified that this allows `react-native-svg` to build against `[email protected]` (after upgrading it from `@react-native-community/[email protected]`). Closes #154. Unblocks software-mansion/react-native-svg#1993.
1 parent bf2408a commit 57755e5

File tree

1 file changed

+0
-3
lines changed
  • packages/react-native-builder-bob/src/utils

1 file changed

+0
-3
lines changed

packages/react-native-builder-bob/src/utils/compile.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ export default async function compile({
9090
require.resolve('@babel/preset-typescript'),
9191
require.resolve('@babel/preset-flow'),
9292
],
93-
plugins: [
94-
require.resolve('@babel/plugin-proposal-class-properties'),
95-
],
9693
}),
9794
});
9895

0 commit comments

Comments
 (0)