Skip to content

[Compiler Todo]: (BuildHIR::lowerExpression) Handle MetaProperty expressions #29737

Closed
@nikeee

Description

@nikeee

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEAhgBQCURwAOsUTAjrMXgLYAOEMOAdG0xK8EmAG4BuOgF8QUoA

Repro steps

I'm using compile-time env vars using Vite. It works by accessing import.meta.env.VITE_VAR_NAME. The react compiler does not seem to handle these expressions:

function a() {
  return import.meta.env;
}

Since react-compiler cannot know to what value anything on the import.meta object resolves, it should just be passed down, resulting in the same code.

Note:
I tried to implement support for it, but I'm not able to test it aside from running it in the playground:
https://github.com/facebook/react/compare/main...nikeee:react:meta-property?expand=1

The test runner does not support anything related to import, since the code must be executed as a module, which is not possible in eval.

How often does this bug happen?

Every time

What version of React are you using?

19

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions