Commit Graph

30 Commits

Author SHA1 Message Date
lauren
ad09027c16
[compiler] Add missing copyrights (#33004)
`yarn copyright`
2025-04-23 22:04:44 -04:00
Tyler Scott Williams
ef06b54f8d
fix: clarify which mobx libs are not compatible with compiler (#32570)
## Summary

Right now, `react-compiler-healthcheck` flags `mobx` as a "known
incompatible library". But it's not precisely *MobX* that's
incompatible. It's the observer HOC that comes from `mobx-react` and
`mobx-react-lite`.

I've been working on
[mst-use-observable](https://github.com/coolsoftwaretyler/mst-use-observable),
which makes MobX-State-Tree compatible with the compiler. However,
projects that use `mobx-state-tree` and `mst-use-observable` will still
depend on `mobx` as a dependency.

And there [have been efforts in the past to write a hook for
observability](https://github.com/mobxjs/mobx/discussions/2566). So it's
possible that MobX could become compatible, so long as authors access it
with a hook, rather than the HOC.

I would like to propose updating the health check to be a little more
precise and flag the HOC dependencies, rather than MobX itself.

Thanks in advance for your consideration!

## How did you test this change?

`npx react-compiler-healthcheck` shouldn't flag on `mobx` in
dependencies, but will for `mobx-react-lite` and `mobx-react`.

Test suites, formatting, linting, all passed.

---------

Co-authored-by: lauren <poteto@users.noreply.github.com>
2025-03-13 11:46:26 -04:00
lauren
00aa0043c7
[compiler] Migrate compiler packages to tsup (#32550)
Currently in the `compiler` workspace, we invoke esbuild directly to
build most packages (with the exception of `snap`). This has been mostly
fine, but does not allow us to do things like generate type declaration
files.

I would like #32416 to be able to consume the merged
eslint-plugin-react-compiler from source rather than via npm, and one of
the things that has come up from my exploration in that stack using the
compiler from source is that babel-plugin-react-compiler is missing type
declarations. This is primarily because React's build process uses
rollup + rollup-plugin-typescript, which runs tsc. So the merged plugin
needs to typecheck properly in order to build. An alternative might be
to migrate to something like babel with rollup instead to simply strip
types rather than typecheck before building. The minor downside of that
approach is that we would need to manually maintain a d.ts file for
eslint-plugin-react-hooks. For now I would like to see if this PR helps
us make progress rather than go for the slightly worse alternative.

[`tsup`](https://github.com/egoist/tsup) is esbuild based so build
performance is comparable. It is slower when generating d.ts files, but
it's still much faster than rollup which we used prior to esbuild. For
now, I have turned off `dts` by default, and it is only passed when
publishing on npm.

If you want to also generate d.ts files you can run `yarn build --dts`.

```
# BEFORE: build all compiler packages (esbuild)
$ time yarn build

  Done in 15.61s.
yarn build  13.82s user 1.54s system 96% cpu 15.842 total

# ---

# AFTER: build all compiler packages (tsup)
$ time yarn build

  Done in 12.39s.
yarn build  12.58s user 1.68s system 106% cpu 13.350 total

# ---

# AFTER: build all compiler packages and type declarations (tsup)
$ time yarn build --dts

  Done in 30.69s.
yarn build  43.57s user 3.20s system 150% cpu 31.061 total
```

I still need to test if this unblocks #32416 but this stack can be
landed independently though as we could probably just release type
declarations on npm. No one should be using the compiler directly, but
if they really wanted to, lack of type declarations would not stop them
(cf React secret internals).

Note that I still kept esbuild as we still use it directly for forgive.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32550).
* #32551
* __->__ #32550
2025-03-07 16:41:55 -05:00
Jeremy JIANG
dc44bca85b
fix(react-compiler-healthcheck): Add shebang to banner (#32225)
## Summary

PR https://github.com/facebook/react/pull/31963 migrated the bundler
from Rollup to esbuild, but the `react-compiler-healthcheck` script
lacks a shebang, leading to issues with `npx` not being able to execute
it.


dc7578290f/compiler/packages/react-compiler-healthcheck/rollup.config.js (L60-L78)


9eabb37338/compiler/packages/react-compiler-healthcheck/scripts/build.js (L38-L53)

## How did you test this change?

**Before**

(fail)

```shell
(main)> npx --version
10.5.0
(main)> npx react-compiler-healthcheck
/home/jeremy/.npm/_npx/67b118a83a29962c/node_modules/.bin/react-compiler-healthcheck: line 1: /bin: Is a directory
/home/jeremy/.npm/_npx/67b118a83a29962c/node_modules/.bin/react-compiler-healthcheck: line 2: syntax error near unexpected token `('
/home/jeremy/.npm/_npx/67b118a83a29962c/node_modules/.bin/react-compiler-healthcheck: line 2: ` * Copyright (c) Meta Platforms, Inc. and affiliates.'
```

**After**

```shell
(main)> npx react-compiler-healthcheck
Successfully compiled 108 out of 146 components.
StrictMode usage not found.
Found no usage of incompatible libraries.
```
2025-01-27 11:59:25 -05:00
lauren
220dece92b
[compiler] Switch to esbuild (#31963)
This migrates the compiler's bundler to esbuild instead of rollup.
Unlike React, our bundling use cases are far simpler since the majority
of our packages are meant to be run on node. Rollup was adding
considerable build time overhead whereas esbuild remains fast and has
all the functionality we need out of the box.


### Before
```
time yarn workspaces run build
yarn workspaces v1.22.22

> babel-plugin-react-compiler
yarn run v1.22.22
$ rimraf dist && rollup --config --bundleConfigAsCjs

src/index.ts → dist/index.js...
(!) Circular dependencies
# ...
created dist/index.js in 15.5s
  Done in 16.45s.

> eslint-plugin-react-compiler
yarn run v1.22.22
$ rimraf dist && rollup --config --bundleConfigAsCjs

src/index.ts → dist/index.js...
(!) Circular dependencies
# ...
created dist/index.js in 9.1s
  Done in 10.11s.

> make-read-only-util
yarn run v1.22.22
warning package.json: No license field
$ tsc
  Done in 1.81s.

> react-compiler-healthcheck
yarn run v1.22.22
$ rimraf dist && rollup --config --bundleConfigAsCjs

src/index.ts → dist/index.js...
(!) Circular dependencies
# ...
created dist/index.js in 8.7s
  Done in 10.43s.

> react-compiler-runtime
yarn run v1.22.22
$ rimraf dist && rollup --config --bundleConfigAsCjs

src/index.ts → dist/index.js...
(!) src/index.ts (1:0): Module level directives cause errors when bundled, "use no memo" in "src/index.ts" was ignored.
# ...
created dist/index.js in 1.1s
  Done in 1.82s.

> snap
yarn run v1.22.22
$ rimraf dist && concurrently -n snap,runtime "tsc --build" "yarn --silent workspace react-compiler-runtime build --silent"
$ rimraf dist && rollup --config --bundleConfigAsCjs --silent
[runtime] yarn --silent workspace react-compiler-runtime build --silent exited with code 0
[snap] tsc --build exited with code 0
  Done in 5.73s.
  Done in 47.30s.
yarn workspaces run build  75.92s user 5.48s system 170% cpu 47.821 total
```

### After

```
time yarn workspaces run build
yarn workspaces v1.22.22

> babel-plugin-react-compiler
yarn run v1.22.22
$ rimraf dist && scripts/build.js
  Done in 1.02s.

> eslint-plugin-react-compiler
yarn run v1.22.22
$ rimraf dist && scripts/build.js
  Done in 0.93s.

> make-read-only-util
yarn run v1.22.22
warning package.json: No license field
$ rimraf dist && scripts/build.js
  Done in 0.89s.

> react-compiler-healthcheck
yarn run v1.22.22
$ rimraf dist && scripts/build.js
  Done in 0.58s.

> react-compiler-runtime
yarn run v1.22.22
$ rimraf dist && scripts/build.js
  Done in 0.48s.

> snap
yarn run v1.22.22
$ rimraf dist && concurrently -n snap,runtime "tsc --build" "yarn --silent workspace react-compiler-runtime build"
$ rimraf dist && scripts/build.js
[runtime] yarn --silent workspace react-compiler-runtime build exited with code 0
[snap] tsc --build exited with code 0
  Done in 4.69s.
  Done in 9.46s.
yarn workspaces run build  9.70s user 0.99s system 103% cpu 10.329 total
```
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31963).
* #31964
* __->__ #31963
* #31962
2025-01-02 16:59:56 -05:00
lauren
c8c89fab5b
[compiler] Update rollup plugins (#31919)
Update our various compiler rollup plugins.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31919).
* #31927
* #31918
* #31917
* #31916
* __->__ #31919
2025-01-02 11:24:26 -05:00
Ahmed Abdelbaset
f7ee804c22
[compiler] Add git info to package.json files in compiler packages (#30475)
This PR adds the repository field to `compiler/packages/*/package.json`

| eslint-plugin-react-compiler | eslint-plugin-react-hooks |
| --- | --- |
|
![image](https://github.com/user-attachments/assets/3392a496-1ff1-4f36-ab96-cfbe1ed88693)
|
![image](https://github.com/user-attachments/assets/b0605dba-eef7-44fe-9484-979b4814d9fb)
|
2024-07-26 12:56:39 -04:00
Lauren Tan
a0e7ecfc6a
Bump version to 0.0.0-experimental-ab3118d-20240725 2024-07-25 15:46:47 -04:00
Lauren Tan
66968535c6
Bump version to 0.0.0-experimental-176c31a-20240725 2024-07-25 12:27:06 -04:00
Jan Kassens
fd2b3e13d3
Compiler: unfork prettier config (#30205)
Updates the prettier config to format all `.ts` and `.tsx` files in the
repo using the existing defaults and removing overrides.

The first commit in this PR contains the config changes, the second is
just the result of running `yarn prettier-all`.
2024-07-18 17:00:24 -04:00
Lauren Tan
f6b546737e Bump version to 0.0.0-experimental-b130d5f-20240625 2024-06-25 12:42:06 -04:00
Lauren Tan
05a3a7fa8d Bump version to 0.0.0-experimental-c20572a-20240614 2024-06-14 17:21:59 -04:00
Lauren Tan
d77dd31a32 Bump version to 0.0.0-experimental-7054a14-20240601 2024-06-01 08:15:27 +09:00
Josh Wilson
aa3d6c0840
Add react-easy-state to list of known incompatible libraries. (#29661)
Like mobx, this library depends on mutating a Proxied store and breaks reference equality checks.
2024-05-30 16:37:09 -07:00
Lauren Tan
b44263addb Bump version to 0.0.0-experimental-31393f7-20240529 2024-05-29 12:01:36 +09:00
Lauren Tan
9d530e94c4 [compiler:babel] Don't read config files when not running as part of
user's pipeline

When the user app has a babel.config file that is missing the compiler,
strange things happen as babel does some strange merging of options from
the user's config and in various callsites like in our eslint rule and
healthcheck script. To minimize odd behavior, we default to not reading
the user's babel.config

Fixes #29135

ghstack-source-id: d6fdc43c5c
Pull Request resolved: https://github.com/facebook/react/pull/29211
2024-05-29 11:46:27 +09:00
Lauren Tan
c998bb1ed4 [compiler] Run prettier, fix snap
After this is merged, I'll add it to .git-blame-ignore-revs. I can't do
it now as the hash will change after ghstack lands this stack.

ghstack-source-id: 054ca869b7
Pull Request resolved: https://github.com/facebook/react/pull/29214
2024-05-29 11:46:27 +09:00
Abishek Ilango
d3ce0d3ea9
feat(compiler-healthcheck): Support strict mode check for nextjs apps (#29167)
## Summary

Closes #29130 

## How did you test this change?

Run the healthcheck in the compiler playground and the nodejs.org repo
for the next config with a `.mjs` extension. Sanity with Vite React
template.

Signed-off-by: abizek <abishekilango@protonmail.com>
2024-05-20 08:55:35 -07:00
Lauren Tan
597ad74e38 Bump version to 0.0.0-experimental-f978439-20240517 2024-05-17 15:17:05 -07:00
mofeiZ
1d6eebfb7f
[Compiler][script] Dedupe error report counts before reporting in healthcheck (#29085)
Certain compiler passes currently may collect a few error events before
reporting (see
https://github.com/facebook/react/blob/main/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts#L101-L107)
2024-05-17 11:58:15 -07:00
Lauren Tan
149b917c8a Bump version to 0.0.0-experimental-8d5174c-20240515 2024-05-15 17:43:42 -07:00
Sathya Gunasekaran
5e11e7fc20
[heathcheck] Check for namespaced StrictMode (#29076)
Previously, we only checked for StrictMode by searching for
`<StrictMode>` but we should also check for the namespaced version,
`<React.StrictMode>`.

Fixes https://github.com/facebook/react/issues/29075
2024-05-15 14:15:32 -07:00
Lauren Tan
740b7c1b0a Bump version to 0.0.0-experimental-410375f-20240515 2024-05-15 08:05:02 -07:00
Lauren Tan
5a842dbfb1 Fix healthcheck package.json bin field
ghstack-source-id: 28045c6edb342dea125ea8fcea564ce90626f21d
Pull Request resolved: https://github.com/facebook/react-forget/pull/2964
2024-05-14 11:02:29 -04:00
Lauren Tan
ce0c08eaad [healthcheck] Clean up ignorelist and check if deps exist
ghstack-source-id: b6d58988eeb86e657a6db2a481b6c2fe2fba0344
Pull Request resolved: https://github.com/facebook/react-forget/pull/2962
2024-05-13 17:08:31 -04:00
Lauren Tan
669e8d02b1 [healthcheck] Refine glob pattern
ghstack-source-id: 6f9e7f9534
Pull Request resolved: https://github.com/facebook/react-forget/pull/2960
2024-05-11 00:56:48 -04:00
Lauren Tan
9ef7557730 [healthcheck] Don't compile mjs
ghstack-source-id: 087985cd23
Pull Request resolved: https://github.com/facebook/react-forget/pull/2959
2024-05-11 00:56:48 -04:00
Lauren Tan
78da5becaf [healthcheck] Remove console.error
ghstack-source-id: c06d44960c
Pull Request resolved: https://github.com/facebook/react-forget/pull/2958
2024-05-11 00:56:48 -04:00
Lauren Tan
76b7331b0d [healthcheck] Only glob files with certain extensions by default
ghstack-source-id: b8db172669
Pull Request resolved: https://github.com/facebook/react-forget/pull/2957
2024-05-11 00:56:48 -04:00
Lauren Tan
63e5330260 [healthcheck] Rename to react-compiler-healthcheck
Don't really have time to implement the react-compiler/healthcheck
version of this script, so for now i propose we just publish this as
react-compiler-healthcheck

the command for running this would be

```
$ npx react-compiler-healthcheck --src 'whatever/**/*.*'
```

ghstack-source-id: e2c443a912
Pull Request resolved: https://github.com/facebook/react-forget/pull/2956
2024-05-11 00:56:48 -04:00