babel-plugin-react-compiler 0.0.0-experimental-81466cb-20250822 → 0.0.0-experimental-3868508-20250826

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +35 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -56639,7 +56639,7 @@ var require_invariant = __commonJS({
56639
56639
  "../../node_modules/invariant/invariant.js"(exports2, module2) {
56640
56640
  "use strict";
56641
56641
  var NODE_ENV = process.env.NODE_ENV;
56642
- var invariant4 = function(condition, format, a, b, c2, d, e, f) {
56642
+ var invariant5 = function(condition, format, a, b, c2, d, e, f) {
56643
56643
  if (NODE_ENV !== "production") {
56644
56644
  if (format === void 0) {
56645
56645
  throw new Error("invariant requires an error message argument");
@@ -56665,7 +56665,7 @@ var require_invariant = __commonJS({
56665
56665
  throw error;
56666
56666
  }
56667
56667
  };
56668
- module2.exports = invariant4;
56668
+ module2.exports = invariant5;
56669
56669
  }
56670
56670
  });
56671
56671
 
@@ -59289,7 +59289,7 @@ module.exports = __toCommonJS(index_exports);
59289
59289
  // src/Babel/RunReactCompilerBabelPlugin.ts
59290
59290
  var import_core = __toESM(require_lib10());
59291
59291
  var BabelParser = __toESM(require_lib4());
59292
- var import_invariant3 = __toESM(require_invariant());
59292
+ var import_invariant4 = __toESM(require_invariant());
59293
59293
 
59294
59294
  // src/Entrypoint/Gating.ts
59295
59295
  var t = __toESM(require("@babel/types"));
@@ -59532,6 +59532,7 @@ function hasOwnProperty2(obj, key2) {
59532
59532
  }
59533
59533
 
59534
59534
  // src/CompilerError.ts
59535
+ var import_invariant = __toESM(require_invariant());
59535
59536
  var ErrorSeverity = /* @__PURE__ */ ((ErrorSeverity2) => {
59536
59537
  ErrorSeverity2["InvalidJS"] = "InvalidJS";
59537
59538
  ErrorSeverity2["UnsupportedJS"] = "UnsupportedJS";
@@ -59926,14 +59927,23 @@ var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
59926
59927
  ErrorCategory2["FBT"] = "FBT";
59927
59928
  return ErrorCategory2;
59928
59929
  })(ErrorCategory || {});
59930
+ var RULE_NAME_PATTERN = /^[a-z]+(-[a-z]+)*$/;
59929
59931
  function getRuleForCategory(category) {
59932
+ const rule = getRuleForCategoryImpl(category);
59933
+ (0, import_invariant.default)(
59934
+ RULE_NAME_PATTERN.test(rule.name),
59935
+ `Invalid rule name, got '${rule.name}' but rules must match ${RULE_NAME_PATTERN.toString()}`
59936
+ );
59937
+ return rule;
59938
+ }
59939
+ function getRuleForCategoryImpl(category) {
59930
59940
  switch (category) {
59931
59941
  case "AutomaticEffectDependencies" /* AutomaticEffectDependencies */: {
59932
59942
  return {
59933
59943
  category,
59934
59944
  name: "automatic-effect-dependencies",
59935
59945
  description: "Verifies that automatic effect dependencies are compiled if opted-in",
59936
- recommended: true
59946
+ recommended: false
59937
59947
  };
59938
59948
  }
59939
59949
  case "CapitalizedCalls" /* CapitalizedCalls */: {
@@ -59948,7 +59958,7 @@ function getRuleForCategory(category) {
59948
59958
  return {
59949
59959
  category,
59950
59960
  name: "config",
59951
- description: "Validates the configuration",
59961
+ description: "Validates the compiler configuration options",
59952
59962
  recommended: true
59953
59963
  };
59954
59964
  }
@@ -59972,7 +59982,7 @@ function getRuleForCategory(category) {
59972
59982
  return {
59973
59983
  category,
59974
59984
  name: "set-state-in-effect",
59975
- description: "Validates against calling setState synchronously in an effect",
59985
+ description: "Validates against calling setState synchronously in an effect, which can lead to re-renders that degrade performance",
59976
59986
  recommended: true
59977
59987
  };
59978
59988
  }
@@ -59980,7 +59990,7 @@ function getRuleForCategory(category) {
59980
59990
  return {
59981
59991
  category,
59982
59992
  name: "error-boundaries",
59983
- description: "Validates usage of error boundaries instead of try/catch for errors in JSX",
59993
+ description: "Validates usage of error boundaries instead of try/catch for errors in child components",
59984
59994
  recommended: true
59985
59995
  };
59986
59996
  }
@@ -60004,7 +60014,7 @@ function getRuleForCategory(category) {
60004
60014
  return {
60005
60015
  category,
60006
60016
  name: "gating",
60007
- description: "Validates configuration of gating mode",
60017
+ description: "Validates configuration of [gating mode](https://react.dev/reference/react-compiler/gating)",
60008
60018
  recommended: true
60009
60019
  };
60010
60020
  }
@@ -60012,7 +60022,7 @@ function getRuleForCategory(category) {
60012
60022
  return {
60013
60023
  category,
60014
60024
  name: "globals",
60015
- description: "Validates against assignment/mutation of globals during render",
60025
+ description: "Validates against assignment/mutation of globals during render, part of ensuring that [side effects must render outside of render](https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)",
60016
60026
  recommended: true
60017
60027
  };
60018
60028
  }
@@ -60033,7 +60043,7 @@ function getRuleForCategory(category) {
60033
60043
  return {
60034
60044
  category,
60035
60045
  name: "immutability",
60036
- description: "Validates that immutable values (props, state, etc) are not mutated",
60046
+ description: "Validates against mutating props, state, and other values that [are immutable](https://react.dev/reference/rules/components-and-hooks-must-be-pure#props-and-state-are-immutable)",
60037
60047
  recommended: true
60038
60048
  };
60039
60049
  }
@@ -60049,7 +60059,7 @@ function getRuleForCategory(category) {
60049
60059
  return {
60050
60060
  category,
60051
60061
  name: "preserve-manual-memoization",
60052
- description: "Validates that existing manual memoized is preserved by the compiler",
60062
+ description: "Validates that existing manual memoized is preserved by the compiler. React Compiler will only compile components and hooks if its inference [matches or exceeds the existing manual memoization](https://react.dev/learn/react-compiler/introduction#what-should-i-do-about-usememo-usecallback-and-reactmemo)",
60053
60063
  recommended: true
60054
60064
  };
60055
60065
  }
@@ -60057,7 +60067,7 @@ function getRuleForCategory(category) {
60057
60067
  return {
60058
60068
  category,
60059
60069
  name: "purity",
60060
- description: "Validates that the component/hook is pure, and does not call known-impure functions",
60070
+ description: "Validates that [components/hooks are pure](https://react.dev/reference/rules/components-and-hooks-must-be-pure) by checking that they do not call known-impure functions",
60061
60071
  recommended: true
60062
60072
  };
60063
60073
  }
@@ -60065,7 +60075,7 @@ function getRuleForCategory(category) {
60065
60075
  return {
60066
60076
  category,
60067
60077
  name: "refs",
60068
- description: "Validates correct usage of refs, not reading/writing during render",
60078
+ description: 'Validates correct usage of refs, not reading/writing during render. See the "pitfalls" section in [`useRef()` usage](https://react.dev/reference/react/useRef#usage)',
60069
60079
  recommended: true
60070
60080
  };
60071
60081
  }
@@ -60073,7 +60083,7 @@ function getRuleForCategory(category) {
60073
60083
  return {
60074
60084
  category,
60075
60085
  name: "set-state-in-render",
60076
- description: "Validates against setting state during render",
60086
+ description: "Validates against setting state during render, which can trigger additional renders and potential infinite render loops",
60077
60087
  recommended: true
60078
60088
  };
60079
60089
  }
@@ -60081,7 +60091,7 @@ function getRuleForCategory(category) {
60081
60091
  return {
60082
60092
  category,
60083
60093
  name: "static-components",
60084
- description: "Validates that components are static, not recreated every render",
60094
+ description: "Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering",
60085
60095
  recommended: true
60086
60096
  };
60087
60097
  }
@@ -60113,7 +60123,7 @@ function getRuleForCategory(category) {
60113
60123
  return {
60114
60124
  category,
60115
60125
  name: "unsupported-syntax",
60116
- description: "Validates against syntax that we do not plan to support",
60126
+ description: "Validates against syntax that we do not plan to support in React Compiler",
60117
60127
  recommended: true
60118
60128
  };
60119
60129
  }
@@ -60121,7 +60131,7 @@ function getRuleForCategory(category) {
60121
60131
  return {
60122
60132
  category,
60123
60133
  name: "use-memo",
60124
- description: "Validates usage of the useMemo() hook",
60134
+ description: "Validates usage of the useMemo() hook against common mistakes. See [`useMemo()` docs](https://react.dev/reference/react/useMemo) for more information.",
60125
60135
  recommended: true
60126
60136
  };
60127
60137
  }
@@ -67278,7 +67288,7 @@ function validateMutableRange(place, range, description) {
67278
67288
  }
67279
67289
 
67280
67290
  // src/HIR/BuildHIR.ts
67281
- var import_invariant = __toESM(require_invariant());
67291
+ var import_invariant2 = __toESM(require_invariant());
67282
67292
 
67283
67293
  // src/HIR/HIRBuilder.ts
67284
67294
  function newBlock(id, kind) {
@@ -71947,7 +71957,7 @@ function isReorderableExpression(builder, expr, allowLocalIdentifiers) {
71947
71957
  if (body.node.type === "BlockStatement") {
71948
71958
  return body.node.body.length === 0;
71949
71959
  } else {
71950
- (0, import_invariant.default)(body.isExpression(), "Expected an expression");
71960
+ (0, import_invariant2.default)(body.isExpression(), "Expected an expression");
71951
71961
  return isReorderableExpression(
71952
71962
  builder,
71953
71963
  body,
@@ -72900,7 +72910,7 @@ function gatherCapturedContext(fn, componentScope) {
72900
72910
  while (current.isJSXMemberExpression()) {
72901
72911
  current = current.get("object");
72902
72912
  }
72903
- (0, import_invariant.default)(
72913
+ (0, import_invariant2.default)(
72904
72914
  current.isJSXIdentifier(),
72905
72915
  "Invalid logic in gatherCapturedDeps"
72906
72916
  );
@@ -94442,7 +94452,7 @@ function validateNoJSXInTryStatement(fn) {
94442
94452
  }
94443
94453
 
94444
94454
  // src/Optimization/OutlineJsx.ts
94445
- var import_invariant2 = __toESM(require_invariant());
94455
+ var import_invariant3 = __toESM(require_invariant());
94446
94456
  function outlineJSX(fn) {
94447
94457
  const outlinedFns = [];
94448
94458
  outlineJsxImpl(fn, outlinedFns);
@@ -94735,7 +94745,7 @@ function emitUpdatedJsx(jsx, oldToNewProps) {
94735
94745
  const { value } = instr;
94736
94746
  const newProps = [];
94737
94747
  for (const prop of value.props) {
94738
- (0, import_invariant2.default)(
94748
+ (0, import_invariant3.default)(
94739
94749
  prop.kind === "JsxAttribute",
94740
94750
  `Expected only attributes but found ${prop.kind}`
94741
94751
  );
@@ -94743,7 +94753,7 @@ function emitUpdatedJsx(jsx, oldToNewProps) {
94743
94753
  continue;
94744
94754
  }
94745
94755
  const newProp = oldToNewProps.get(prop.place.identifier.id);
94746
- (0, import_invariant2.default)(
94756
+ (0, import_invariant3.default)(
94747
94757
  newProp !== void 0,
94748
94758
  `Expected a new property for ${printIdentifier(prop.place.identifier)}`
94749
94759
  );
@@ -94762,7 +94772,7 @@ function emitUpdatedJsx(jsx, oldToNewProps) {
94762
94772
  continue;
94763
94773
  }
94764
94774
  const newChild = oldToNewProps.get(child.identifier.id);
94765
- (0, import_invariant2.default)(
94775
+ (0, import_invariant3.default)(
94766
94776
  newChild !== void 0,
94767
94777
  `Expected a new prop for ${printIdentifier(child.identifier)}`
94768
94778
  );
@@ -97781,7 +97791,7 @@ function runBabelPluginReactCompiler(text, file, language, options, includeAst =
97781
97791
  configFile: false,
97782
97792
  babelrc: false
97783
97793
  });
97784
- (0, import_invariant3.default)(
97794
+ (0, import_invariant4.default)(
97785
97795
  (result == null ? void 0 : result.code) != null,
97786
97796
  `Expected BabelPluginReactForget to codegen successfully, got: ${result}`
97787
97797
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-react-compiler",
3
- "version": "0.0.0-experimental-81466cb-20250822",
3
+ "version": "0.0.0-experimental-3868508-20250826",
4
4
  "description": "Babel plugin for React Compiler.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",