babel-plugin-react-compiler 0.0.0-experimental-df7b47d-20241202 → 0.0.0-experimental-3ab621d-20241203

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 +41 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -136800,6 +136800,10 @@ const testComplexConfigDefaults = {
136800
136800
  },
136801
136801
  numRequiredArgs: 2,
136802
136802
  },
136803
+ {
136804
+ function: {source: 'useEffectWrapper', importSpecifierName: 'default'},
136805
+ numRequiredArgs: 1,
136806
+ },
136803
136807
  ],
136804
136808
  };
136805
136809
  function parseConfigPragmaForTests(pragma) {
@@ -137376,6 +137380,7 @@ function tryParseExternalFunction(maybeExternalFunction) {
137376
137380
  suggestions: null,
137377
137381
  });
137378
137382
  }
137383
+ const DEFAULT_EXPORT = 'default';
137379
137384
  var _MergedBlocks_map;
137380
137385
  function mergeConsecutiveBlocks(fn) {
137381
137386
  const merged = new MergedBlocks();
@@ -139817,7 +139822,15 @@ function addMemoCacheFunctionImportDeclaration(program, moduleName, localName) {
139817
139822
  );
139818
139823
  }
139819
139824
  z.enum(['all_errors', 'critical_errors', 'none']);
139820
- const CompilerReactTargetSchema = z.enum(['17', '18', '19']);
139825
+ const CompilerReactTargetSchema = z.union([
139826
+ z.literal('17'),
139827
+ z.literal('18'),
139828
+ z.literal('19'),
139829
+ z.object({
139830
+ kind: z.literal('donotuse_meta_internal'),
139831
+ runtimeModule: z.string().default('react'),
139832
+ }),
139833
+ ]);
139821
139834
  z.enum(['infer', 'syntax', 'annotation', 'all']);
139822
139835
  const defaultOptions = {
139823
139836
  compilationMode: 'infer',
@@ -151556,6 +151569,17 @@ function inferEffectDependencies(fn) {
151556
151569
  autodepFnLoads.set(lvalue.identifier.id, numRequiredArgs);
151557
151570
  }
151558
151571
  }
151572
+ } else if (
151573
+ value.kind === 'LoadGlobal' &&
151574
+ value.binding.kind === 'ImportDefault'
151575
+ ) {
151576
+ const moduleTargets = autodepFnConfigs.get(value.binding.module);
151577
+ if (moduleTargets != null) {
151578
+ const numRequiredArgs = moduleTargets.get(DEFAULT_EXPORT);
151579
+ if (numRequiredArgs != null) {
151580
+ autodepFnLoads.set(lvalue.identifier.id, numRequiredArgs);
151581
+ }
151582
+ }
151559
151583
  } else if (
151560
151584
  value.kind === 'CallExpression' &&
151561
151585
  autodepFnLoads.get(value.callee.identifier.id) === value.args.length &&
@@ -151660,6 +151684,9 @@ function writeDependencyToInstructions(dep, reactive, env, loc) {
151660
151684
  if (path.optional) {
151661
151685
  break;
151662
151686
  }
151687
+ if (path.property === 'current') {
151688
+ break;
151689
+ }
151663
151690
  const nextValue = createTemporaryPlace(env, GeneratedSource);
151664
151691
  nextValue.reactive = reactive;
151665
151692
  instructions.push({
@@ -158495,26 +158522,24 @@ function checkFunctionReferencedBeforeDeclarationAtTopLevel(program, fns) {
158495
158522
  return errors.details.length > 0 ? errors : null;
158496
158523
  }
158497
158524
  function getReactCompilerRuntimeModule(opts) {
158498
- let moduleName = null;
158499
- switch (opts.target) {
158500
- case '17':
158501
- case '18': {
158502
- moduleName = 'react-compiler-runtime';
158503
- break;
158504
- }
158505
- case '19': {
158506
- moduleName = 'react/compiler-runtime';
158507
- break;
158508
- }
158509
- default:
158510
- CompilerError.invariant(moduleName != null, {
158525
+ if (opts.target === '19') {
158526
+ return 'react/compiler-runtime';
158527
+ } else if (opts.target === '17' || opts.target === '18') {
158528
+ return 'react-compiler-runtime';
158529
+ } else {
158530
+ CompilerError.invariant(
158531
+ opts.target != null &&
158532
+ opts.target.kind === 'donotuse_meta_internal' &&
158533
+ typeof opts.target.runtimeModule === 'string',
158534
+ {
158511
158535
  reason: 'Expected target to already be validated',
158512
158536
  description: null,
158513
158537
  loc: null,
158514
158538
  suggestions: null,
158515
- });
158539
+ }
158540
+ );
158541
+ return opts.target.runtimeModule;
158516
158542
  }
158517
- return moduleName;
158518
158543
  }
158519
158544
  function hasModule(name) {
158520
158545
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-react-compiler",
3
- "version": "0.0.0-experimental-df7b47d-20241202",
3
+ "version": "0.0.0-experimental-3ab621d-20241203",
4
4
  "description": "Babel plugin for React Compiler.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",