Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-process build files for React Native to add generated signature and @nolint #26616

Merged

Conversation

rubennorte
Copy link
Contributor

Summary

We're enabling a new mechanism to synchronize build files from react to react-native. That new mechanism doesn't post-process files, so we need to add that post-processing somewhere. This PR does that when generating the files in the first place, so the generated files in the build directory are ready to be committed in the react-native repository directly.

This makes use of signedsource to avoid direct modifications of these files in the react-native repository, as well as @noformat and @nolint to prevent unactionable CI failures in that repository.

How did you test this change?

Generated build files for react-native before and after this change:

node ./scripts/rollup/build-all-release-channels.js react-native

Checked new contents. Relevant changes:

diff --color -r build-before/react-native/implementations/ReactFabric-dev.fb.js build-after/react-native/implementations/ReactFabric-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<03cef14e77b8250b567dfdf3b066085e>>
diff --color -r build-before/react-native/implementations/ReactFabric-dev.js build-after/react-native/implementations/ReactFabric-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<e39eed38a363846ca9ee9b59a225683c>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.fb.js build-after/react-native/implementations/ReactFabric-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<f65efcd6a469d5f6fef1ce647e5ec09a>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.js build-after/react-native/implementations/ReactFabric-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<cdd582aa889b1054b2c5faf412622b18>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.fb.js build-after/react-native/implementations/ReactFabric-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<81e74849b24f104882bd298f062be0fa>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.js build-after/react-native/implementations/ReactFabric-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<c050b7fa1453dc21ac1c5b98146210a8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.fb.js build-after/react-native/implementations/ReactNativeRenderer-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<9c03464b489b41c06a065aeba8619263>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.js build-after/react-native/implementations/ReactNativeRenderer-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<18b34c037544949dcf9b28f945921ba8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.fb.js build-after/react-native/implementations/ReactNativeRenderer-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<592e9654c584d1da523378b119bd8bd7>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.js build-after/react-native/implementations/ReactNativeRenderer-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<91c894db99e2d76f8a32708ad6ad1bde>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.fb.js build-after/react-native/implementations/ReactNativeRenderer-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<5ce378a9216ea747d91b208b9fd1ebd5>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.js build-after/react-native/implementations/ReactNativeRenderer-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<1c7564f446ee83142976035b2884dcfd>>
diff --color -r build-before/react-native/shims/ReactFabric.js build-after/react-native/shims/ReactFabric.js
7c7
<  * @format
---
>  * @noformat
8a9,10
>  * @nolint
>  * @generated SignedSource<<cece19ddbec9f287c995721f49c68977>>
diff --color -r build-before/react-native/shims/ReactFeatureFlags.js build-after/react-native/shims/ReactFeatureFlags.js
7c7
<  * @format
---
>  * @noformat
8a9,10
>  * @nolint
>  * @generated SignedSource<<2881c8e89ef0f73f4cf6612cb518b197>>
diff --color -r build-before/react-native/shims/ReactNative.js build-after/react-native/shims/ReactNative.js
7c7
<  * @format
---
>  * @noformat
8a9,10
>  * @nolint
>  * @generated SignedSource<<0debd6e5a17dc037cb4661315a886de6>>
diff --color -r build-before/react-native/shims/ReactNativeTypes.js build-after/react-native/shims/ReactNativeTypes.js
7c7
<  * @format
---
>  * @noformat
8a9,10
>  * @nolint
>  * @generated SignedSource<<652b117c94307244bcf5e4af18928903>>
diff --color -r build-before/react-native/shims/ReactNativeViewConfigRegistry.js build-after/react-native/shims/ReactNativeViewConfigRegistry.js
7c7
<  * @format
---
>  * @noformat
8a9,10
>  * @nolint
>  * @generated SignedSource<<ce82e8957367bee7d11379ab88e3f7c5>>
diff --color -r build-before/react-native/shims/createReactNativeComponentClass.js build-after/react-native/shims/createReactNativeComponentClass.js
7c7
<  * @format
---
>  * @noformat
8a9,10
>  * @nolint
>  * @generated SignedSource<<ede54ac2fa1b9a09e234cdf098048989>>

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this is changing the build artifacts that are generated by yarn build? If so, I think the right place to do this is in the diff train workflow, when we sync to the Meta repo. That way, Meta specific needs are not leaked into the build outputs, and stay in the sync pipeline.

@react-sizebot
Copy link

react-sizebot commented Apr 13, 2023

Comparing: 7b0642b...a0dc889

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 164.35 kB 164.35 kB = 51.65 kB 51.65 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 166.79 kB 166.79 kB = 52.31 kB 52.31 kB
facebook-www/ReactDOM-prod.classic.js = 564.28 kB 564.28 kB = 99.34 kB 99.34 kB
facebook-www/ReactDOM-prod.modern.js = 548.07 kB 548.07 kB = 96.64 kB 96.64 kB
react-native/shims/ReactFeatureFlags.js +21.78% 0.35 kB 0.43 kB +23.11% 0.25 kB 0.31 kB
react-native/shims/ReactNative.js +14.48% 0.53 kB 0.60 kB +19.06% 0.30 kB 0.36 kB
facebook-react-native/react/cjs/JSXDEVRuntime-prod.js +12.79% 0.38 kB 0.43 kB +14.86% 0.28 kB 0.32 kB
facebook-react-native/react/cjs/JSXDEVRuntime-profiling.js +12.79% 0.38 kB 0.43 kB +14.86% 0.28 kB 0.32 kB
react-native/shims/ReactFabric.js +9.95% 0.76 kB 0.84 kB +13.48% 0.41 kB 0.46 kB
react-native/shims/createReactNativeComponentClass.js +8.14% 0.93 kB 1.01 kB +11.81% 0.49 kB 0.55 kB
facebook-react-native/react/cjs/JSXRuntime-prod.js +3.40% 1.44 kB 1.49 kB +6.43% 0.68 kB 0.73 kB
facebook-react-native/react/cjs/JSXRuntime-profiling.js +3.40% 1.44 kB 1.49 kB +6.43% 0.68 kB 0.73 kB
react-native/shims/ReactNativeViewConfigRegistry.js +2.09% 3.64 kB 3.72 kB +4.85% 1.24 kB 1.30 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
react-native/shims/ReactFeatureFlags.js +21.78% 0.35 kB 0.43 kB +23.11% 0.25 kB 0.31 kB
react-native/shims/ReactNative.js +14.48% 0.53 kB 0.60 kB +19.06% 0.30 kB 0.36 kB
facebook-react-native/react/cjs/JSXDEVRuntime-prod.js +12.79% 0.38 kB 0.43 kB +14.86% 0.28 kB 0.32 kB
facebook-react-native/react/cjs/JSXDEVRuntime-profiling.js +12.79% 0.38 kB 0.43 kB +14.86% 0.28 kB 0.32 kB
react-native/shims/ReactFabric.js +9.95% 0.76 kB 0.84 kB +13.48% 0.41 kB 0.46 kB
react-native/shims/createReactNativeComponentClass.js +8.14% 0.93 kB 1.01 kB +11.81% 0.49 kB 0.55 kB
facebook-react-native/react/cjs/JSXRuntime-prod.js +3.40% 1.44 kB 1.49 kB +6.43% 0.68 kB 0.73 kB
facebook-react-native/react/cjs/JSXRuntime-profiling.js +3.40% 1.44 kB 1.49 kB +6.43% 0.68 kB 0.73 kB
react-native/shims/ReactNativeViewConfigRegistry.js +2.09% 3.64 kB 3.72 kB +4.85% 1.24 kB 1.30 kB
facebook-react-native/react-is/cjs/ReactIs-prod.js +1.02% 4.80 kB 4.85 kB +4.26% 1.15 kB 1.20 kB
facebook-react-native/react-is/cjs/ReactIs-profiling.js +1.02% 4.80 kB 4.85 kB +4.26% 1.15 kB 1.20 kB
react-native/shims/ReactNativeTypes.js +0.95% 8.04 kB 8.11 kB +3.04% 2.17 kB 2.24 kB
facebook-react-native/react-is/cjs/ReactIs-dev.js +0.68% 7.25 kB 7.29 kB +2.55% 1.92 kB 1.97 kB
facebook-react-native/scheduler/cjs/Scheduler-prod.js +0.47% 10.53 kB 10.58 kB +1.62% 2.66 kB 2.70 kB
facebook-react-native/scheduler/cjs/Scheduler-profiling.js +0.44% 11.14 kB 11.19 kB +1.47% 2.80 kB 2.84 kB
facebook-relay/flight/ReactFlightNativeRelayClient-prod.js +0.40% 12.24 kB 12.29 kB +1.47% 3.12 kB 3.17 kB
facebook-react-native/scheduler/cjs/SchedulerMock-prod.js +0.40% 12.30 kB 12.34 kB +1.49% 2.89 kB 2.93 kB
facebook-react-native/scheduler/cjs/SchedulerMock-dev.js +0.27% 17.99 kB 18.04 kB +1.00% 4.32 kB 4.36 kB
facebook-react-native/scheduler/cjs/Scheduler-dev.js +0.27% 18.08 kB 18.12 kB +0.81% 5.09 kB 5.13 kB
facebook-relay/flight/ReactFlightNativeRelayClient-dev.js +0.24% 20.41 kB 20.46 kB +0.94% 5.30 kB 5.35 kB
facebook-react-native/react/cjs/React-prod.js +0.23% 21.13 kB 21.18 kB +0.89% 5.27 kB 5.31 kB
facebook-react-native/react/cjs/React-profiling.js +0.23% 21.44 kB 21.49 kB +0.86% 5.32 kB 5.37 kB

Generated by 🚫 dangerJS against a0dc889

@rubennorte
Copy link
Contributor Author

If I understand correctly, this is changing the build artifacts that are generated by yarn build? If so, I think the right place to do this is in the diff train workflow, when we sync to the Meta repo. That way, Meta specific needs are not leaked into the build outputs, and stay in the sync pipeline.

@rickhanlonii these generated files are already react-native specific, and I'm just adjusting the build process to generate them the way we're going to consume them in react-native. What part did you think it didn't belong here? Adding @nolint or replacing @generated with its signed counterpart?

@rubennorte rubennorte force-pushed the postprocess-react-native-build-files branch from ae56fe4 to 26c4e58 Compare April 13, 2023 13:37
@rubennorte rubennorte force-pushed the postprocess-react-native-build-files branch from 26c4e58 to a0dc889 Compare April 13, 2023 14:31
@rickhanlonii
Copy link
Member

Both, in my mind. The sync script used to add that during the sync, so the equivalent layer of that is the diff train sync script. Concretely, we shouldn't see the meta specific comments in the https://react-builds.vercel.app/ tool, or take the extra time to generate the shas during yarn build, or need to maintain this if we make changes to the build scripts.

@rubennorte rubennorte merged commit 39a3b72 into facebook:main Apr 14, 2023
@rubennorte rubennorte deleted the postprocess-react-native-build-files branch April 14, 2023 09:47
kassens pushed a commit to kassens/react that referenced this pull request Apr 17, 2023
…and @NOLINT (facebook#26616)

## Summary

We're enabling a new mechanism to synchronize build files from `react`
to `react-native`. That new mechanism doesn't post-process files, so we
need to add that post-processing somewhere. This PR does that when
generating the files in the first place, so the generated files in the
`build` directory are ready to be committed in the `react-native`
repository directly.

This makes use of `signedsource` to avoid direct modifications of these
files in the `react-native` repository, as well as `@noformat` and
`@nolint` to prevent unactionable CI failures in that repository.

## How did you test this change?

Generated build files for `react-native` before and after this change:
```
node ./scripts/rollup/build-all-release-channels.js react-native
```

Checked new contents. Relevant changes:

```diff
diff --color -r build-before/react-native/implementations/ReactFabric-dev.fb.js build-after/react-native/implementations/ReactFabric-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<03cef14e77b8250b567dfdf3b066085e>>
diff --color -r build-before/react-native/implementations/ReactFabric-dev.js build-after/react-native/implementations/ReactFabric-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<e39eed38a363846ca9ee9b59a225683c>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.fb.js build-after/react-native/implementations/ReactFabric-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<f65efcd6a469d5f6fef1ce647e5ec09a>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.js build-after/react-native/implementations/ReactFabric-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<cdd582aa889b1054b2c5faf412622b18>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.fb.js build-after/react-native/implementations/ReactFabric-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<81e74849b24f104882bd298f062be0fa>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.js build-after/react-native/implementations/ReactFabric-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<c050b7fa1453dc21ac1c5b98146210a8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.fb.js build-after/react-native/implementations/ReactNativeRenderer-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<9c03464b489b41c06a065aeba8619263>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.js build-after/react-native/implementations/ReactNativeRenderer-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<18b34c037544949dcf9b28f945921ba8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.fb.js build-after/react-native/implementations/ReactNativeRenderer-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<592e9654c584d1da523378b119bd8bd7>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.js build-after/react-native/implementations/ReactNativeRenderer-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<91c894db99e2d76f8a32708ad6ad1bde>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.fb.js build-after/react-native/implementations/ReactNativeRenderer-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<5ce378a9216ea747d91b208b9fd1ebd5>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.js build-after/react-native/implementations/ReactNativeRenderer-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<1c7564f446ee83142976035b2884dcfd>>
diff --color -r build-before/react-native/shims/ReactFabric.js build-after/react-native/shims/ReactFabric.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<cece19ddbec9f287c995721f49c68977>>
diff --color -r build-before/react-native/shims/ReactFeatureFlags.js build-after/react-native/shims/ReactFeatureFlags.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<2881c8e89ef0f73f4cf6612cb518b197>>
diff --color -r build-before/react-native/shims/ReactNative.js build-after/react-native/shims/ReactNative.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<0debd6e5a17dc037cb4661315a886de6>>
diff --color -r build-before/react-native/shims/ReactNativeTypes.js build-after/react-native/shims/ReactNativeTypes.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<652b117c94307244bcf5e4af18928903>>
diff --color -r build-before/react-native/shims/ReactNativeViewConfigRegistry.js build-after/react-native/shims/ReactNativeViewConfigRegistry.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<ce82e8957367bee7d11379ab88e3f7c5>>
diff --color -r build-before/react-native/shims/createReactNativeComponentClass.js build-after/react-native/shims/createReactNativeComponentClass.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<ede54ac2fa1b9a09e234cdf098048989>>
```
@markerikson
Copy link
Contributor

This PR seems to have broken my ability to build React locally :(

Context:

I just tried to merge main into these branches to pick up the latest changes. #26446 builds okay in CI. But, any build that includes these changes (whether I'm building straight from main or my sourcemaps branch + main) fails with:

Error: SignedSource.signFile(...): Cannot sign file without token: <<SignedSource::*O*zOeWoEQle#+L!plEphiEmie@IsG>>
    at Object.<anonymous> (C:\Projects\react\node_modules\signedsource\index.js:20:28)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (C:\Projects\react\scripts\rollup\packaging.js:18:37)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)

This happens with both yarn build and yarn build-for-devtools.

It appears that it's coming from these steps in scripts/rollup/packaging.js:

async function copyRNShims() {
  await asyncCopyTo(
    `${__dirname}/shims/react-native`,
    'build/react-native/shims'
  );
  await asyncCopyTo(
    require.resolve('react-native-renderer/src/ReactNativeTypes.js'),
    'build/react-native/shims/ReactNativeTypes.js'
  );
  processGenerated('build/react-native/shims');
}

function processGenerated(directory) {
  const files = readdirSync(directory)
    .filter(dir => dir.endsWith('.js'))
    .map(file => path.join(directory, file));

  files.forEach(file => {
    const originalContents = readFileSync(file, 'utf8');
    const contents = originalContents
      // Replace {@}format with {@}noformat
      .replace(/(\n\s*\*\s*)@format\b.*(\n)/, '$1@noformat$2')
      // Add {@}nolint and {@}generated
      .replace(' */\n', ` * @nolint\n * ${getSigningToken()}\n */\n`);
    const signedContents = signFile(contents);
    writeFileSync(file, signedContents, 'utf8');
  });
}

and specifically from trying to process build\react-native\shims\createReactNativeComponentClass.js:

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * @flow strict-local
 */

'use strict';

import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
import {type ViewConfig} from './ReactNativeTypes';

const {register} = ReactNativeViewConfigRegistry;

/**
 * Creates a renderable ReactNative host component.
 * Use this method for view configs that are loaded from UIManager.
 * Use createReactNativeComponentClass() for view configs defined within JavaScript.
 *
 * @param {string} config iOS View configuration.
 * @private
 */
const createReactNativeComponentClass = function (
  name: string,
  callback: () => ViewConfig,
): string {
  return register(name, callback);
};

module.exports = createReactNativeComponentClass;

Given that the shim file doesn't have a token-related string in it, I think the error sort of makes sense conceptually.

I'm not sure what would be missing or different on my end that would make this fail, or why no one else seems to have reported it yet.

Any suggestions on getting the build process working for me again?

@markerikson
Copy link
Contributor

Someone else is seeing the same issue in #26697

@rubennorte
Copy link
Contributor Author

Thanks for reporting @markerikson! I think this is a Windows-specific issue related to line endings. Working on a fix now. I'll follow up on #26697.

rubennorte added a commit that referenced this pull request Apr 25, 2023
## Summary

We added some post-processing in the build for RN in #26616 that broke
for users on Windows due to how line endings were handled to the regular
expression to insert some directives in the docblock. This fixes that
problem, reported in #26697 as well.

## How did you test this change?

Verified files are still built correctly on Mac/Linux. Will ask for help
to test on Windows.
github-actions bot pushed a commit that referenced this pull request Apr 25, 2023
## Summary

We added some post-processing in the build for RN in #26616 that broke
for users on Windows due to how line endings were handled to the regular
expression to insert some directives in the docblock. This fixes that
problem, reported in #26697 as well.

## How did you test this change?

Verified files are still built correctly on Mac/Linux. Will ask for help
to test on Windows.

DiffTrain build for [f87e97a](f87e97a)
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…and @NOLINT (facebook#26616)

## Summary

We're enabling a new mechanism to synchronize build files from `react`
to `react-native`. That new mechanism doesn't post-process files, so we
need to add that post-processing somewhere. This PR does that when
generating the files in the first place, so the generated files in the
`build` directory are ready to be committed in the `react-native`
repository directly.

This makes use of `signedsource` to avoid direct modifications of these
files in the `react-native` repository, as well as `@noformat` and
`@nolint` to prevent unactionable CI failures in that repository.

## How did you test this change?

Generated build files for `react-native` before and after this change:
```
node ./scripts/rollup/build-all-release-channels.js react-native
```

Checked new contents. Relevant changes:

```diff
diff --color -r build-before/react-native/implementations/ReactFabric-dev.fb.js build-after/react-native/implementations/ReactFabric-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<03cef14e77b8250b567dfdf3b066085e>>
diff --color -r build-before/react-native/implementations/ReactFabric-dev.js build-after/react-native/implementations/ReactFabric-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<e39eed38a363846ca9ee9b59a225683c>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.fb.js build-after/react-native/implementations/ReactFabric-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<f65efcd6a469d5f6fef1ce647e5ec09a>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.js build-after/react-native/implementations/ReactFabric-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<cdd582aa889b1054b2c5faf412622b18>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.fb.js build-after/react-native/implementations/ReactFabric-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<81e74849b24f104882bd298f062be0fa>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.js build-after/react-native/implementations/ReactFabric-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<c050b7fa1453dc21ac1c5b98146210a8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.fb.js build-after/react-native/implementations/ReactNativeRenderer-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<9c03464b489b41c06a065aeba8619263>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.js build-after/react-native/implementations/ReactNativeRenderer-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<18b34c037544949dcf9b28f945921ba8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.fb.js build-after/react-native/implementations/ReactNativeRenderer-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<592e9654c584d1da523378b119bd8bd7>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.js build-after/react-native/implementations/ReactNativeRenderer-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<91c894db99e2d76f8a32708ad6ad1bde>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.fb.js build-after/react-native/implementations/ReactNativeRenderer-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<5ce378a9216ea747d91b208b9fd1ebd5>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.js build-after/react-native/implementations/ReactNativeRenderer-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<1c7564f446ee83142976035b2884dcfd>>
diff --color -r build-before/react-native/shims/ReactFabric.js build-after/react-native/shims/ReactFabric.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<cece19ddbec9f287c995721f49c68977>>
diff --color -r build-before/react-native/shims/ReactFeatureFlags.js build-after/react-native/shims/ReactFeatureFlags.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<2881c8e89ef0f73f4cf6612cb518b197>>
diff --color -r build-before/react-native/shims/ReactNative.js build-after/react-native/shims/ReactNative.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<0debd6e5a17dc037cb4661315a886de6>>
diff --color -r build-before/react-native/shims/ReactNativeTypes.js build-after/react-native/shims/ReactNativeTypes.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<652b117c94307244bcf5e4af18928903>>
diff --color -r build-before/react-native/shims/ReactNativeViewConfigRegistry.js build-after/react-native/shims/ReactNativeViewConfigRegistry.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<ce82e8957367bee7d11379ab88e3f7c5>>
diff --color -r build-before/react-native/shims/createReactNativeComponentClass.js build-after/react-native/shims/createReactNativeComponentClass.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<ede54ac2fa1b9a09e234cdf098048989>>
```
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…book#26727)

## Summary

We added some post-processing in the build for RN in facebook#26616 that broke
for users on Windows due to how line endings were handled to the regular
expression to insert some directives in the docblock. This fixes that
problem, reported in facebook#26697 as well.

## How did you test this change?

Verified files are still built correctly on Mac/Linux. Will ask for help
to test on Windows.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
…and @NOLINT (#26616)

## Summary

We're enabling a new mechanism to synchronize build files from `react`
to `react-native`. That new mechanism doesn't post-process files, so we
need to add that post-processing somewhere. This PR does that when
generating the files in the first place, so the generated files in the
`build` directory are ready to be committed in the `react-native`
repository directly.

This makes use of `signedsource` to avoid direct modifications of these
files in the `react-native` repository, as well as `@noformat` and
`@nolint` to prevent unactionable CI failures in that repository.

## How did you test this change?

Generated build files for `react-native` before and after this change:
```
node ./scripts/rollup/build-all-release-channels.js react-native
```

Checked new contents. Relevant changes:

```diff
diff --color -r build-before/react-native/implementations/ReactFabric-dev.fb.js build-after/react-native/implementations/ReactFabric-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<03cef14e77b8250b567dfdf3b066085e>>
diff --color -r build-before/react-native/implementations/ReactFabric-dev.js build-after/react-native/implementations/ReactFabric-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<e39eed38a363846ca9ee9b59a225683c>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.fb.js build-after/react-native/implementations/ReactFabric-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<f65efcd6a469d5f6fef1ce647e5ec09a>>
diff --color -r build-before/react-native/implementations/ReactFabric-prod.js build-after/react-native/implementations/ReactFabric-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<cdd582aa889b1054b2c5faf412622b18>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.fb.js build-after/react-native/implementations/ReactFabric-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<81e74849b24f104882bd298f062be0fa>>
diff --color -r build-before/react-native/implementations/ReactFabric-profiling.js build-after/react-native/implementations/ReactFabric-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<c050b7fa1453dc21ac1c5b98146210a8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.fb.js build-after/react-native/implementations/ReactNativeRenderer-dev.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<9c03464b489b41c06a065aeba8619263>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-dev.js build-after/react-native/implementations/ReactNativeRenderer-dev.js
11c11
<  * @generated
---
>  * @generated SignedSource<<18b34c037544949dcf9b28f945921ba8>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.fb.js build-after/react-native/implementations/ReactNativeRenderer-prod.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<592e9654c584d1da523378b119bd8bd7>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-prod.js build-after/react-native/implementations/ReactNativeRenderer-prod.js
11c11
<  * @generated
---
>  * @generated SignedSource<<91c894db99e2d76f8a32708ad6ad1bde>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.fb.js build-after/react-native/implementations/ReactNativeRenderer-profiling.fb.js
10c10
<  * @generated
---
>  * @generated SignedSource<<5ce378a9216ea747d91b208b9fd1ebd5>>
diff --color -r build-before/react-native/implementations/ReactNativeRenderer-profiling.js build-after/react-native/implementations/ReactNativeRenderer-profiling.js
11c11
<  * @generated
---
>  * @generated SignedSource<<1c7564f446ee83142976035b2884dcfd>>
diff --color -r build-before/react-native/shims/ReactFabric.js build-after/react-native/shims/ReactFabric.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<cece19ddbec9f287c995721f49c68977>>
diff --color -r build-before/react-native/shims/ReactFeatureFlags.js build-after/react-native/shims/ReactFeatureFlags.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<2881c8e89ef0f73f4cf6612cb518b197>>
diff --color -r build-before/react-native/shims/ReactNative.js build-after/react-native/shims/ReactNative.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<0debd6e5a17dc037cb4661315a886de6>>
diff --color -r build-before/react-native/shims/ReactNativeTypes.js build-after/react-native/shims/ReactNativeTypes.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<652b117c94307244bcf5e4af18928903>>
diff --color -r build-before/react-native/shims/ReactNativeViewConfigRegistry.js build-after/react-native/shims/ReactNativeViewConfigRegistry.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<ce82e8957367bee7d11379ab88e3f7c5>>
diff --color -r build-before/react-native/shims/createReactNativeComponentClass.js build-after/react-native/shims/createReactNativeComponentClass.js
7c7
<  * @Format
---
>  * @noformat
8a9,10
>  * @NOLINT
>  * @generated SignedSource<<ede54ac2fa1b9a09e234cdf098048989>>
```

DiffTrain build for commit 39a3b72.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
## Summary

We added some post-processing in the build for RN in #26616 that broke
for users on Windows due to how line endings were handled to the regular
expression to insert some directives in the docblock. This fixes that
problem, reported in #26697 as well.

## How did you test this change?

Verified files are still built correctly on Mac/Linux. Will ask for help
to test on Windows.

DiffTrain build for commit f87e97a.
rickhanlonii added a commit that referenced this pull request Jun 10, 2024
## Overview

Reverts #26616 and implements the
suggested way instead.

This change in #26616 broken the internal sync command, which now
results in duplicated `@generated` headers. It also makes it harder to
detect changes during the diff train sync. Instead, we will check for
changes, and if there are changes sign the files and commit them to the
sync branch.

## Strategy

The new sync strategy accounts for the generated headers during the
sync:
- **Revert Version**: Revert the version strings
- **Revert @generated**: Re-sign the files (will be the same hash as
before if unchanged)
- **Check**: Check if there are changes **if not, skip**
- **Re-apply Version**: Now add back the new version string
- **Re-sign @generated**: And re-generate the headers

Then commit to branch. This ensures that if there are no changes, we'll
skip.

---------

Co-authored-by: Timothy Yung <yungsters@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants