stylex icon indicating copy to clipboard operation
stylex copied to clipboard

@stylexjs/babel-plugin `runtimeInjection` option behavior change between 0.3 and 0.4

Open HorusGoul opened this issue 2 years ago • 1 comments

The problem

There are cases in which we might want runtimeInjection: false (like when developing an SSR app), but we still want to use dev: true to provide dev friendly class names.

On the latest version of @stylexjs/babel-plugin, the code changed from

https://github.com/facebook/stylex/blob/4e1be339307785e805caf9c1b0ec0618b81e3a44/packages/babel-plugin/src/utils/state-manager.js#L86-L87

to

https://github.com/facebook/stylex/blob/a3528b69d567bcf5c61c6e92e86312bcac8e6122/packages/babel-plugin/src/utils/state-manager.js#L99-L106

Before, the plugin used ??, which checked for null and undefined; now, it uses ternaries, which check for falseness. This means it will ignore an explicit runtimeInjection: false configuration and fall back to checking for dev.

How to reproduce

Steps to reproduce:

  1. Using the babel-plugin, pass dev: true and runtimeInjection: false.
  2. Runtime will be injected.

Expected behavior

Plugin shouldn't inject the runtime if runtimeInjection is set to false

Environment (include versions). Did this work in previous versions? 0.4.1 version of the babel plugin. It did work in 0.3.0.

HorusGoul avatar Jan 04 '24 17:01 HorusGoul

I already have a PR up to fix this. #298

nmn avatar Jan 04 '24 23:01 nmn

Fixed in 0.5.0

nmn avatar Jan 26 '24 06:01 nmn