Skip to content

Commit

Permalink
Merge pull request #44460 from margelo/feat/react-compiler-healthcheck
Browse files Browse the repository at this point in the history
[NoQA] feat: react-compiler healthcheck
  • Loading branch information
mountiny authored Jul 8, 2024
2 parents a5fb7cd + 75abab0 commit fe2fcf0
Show file tree
Hide file tree
Showing 155 changed files with 410 additions and 200 deletions.
109 changes: 101 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"workflow-test": "./workflow_tests/scripts/runWorkflowTests.sh",
"workflow-test:generate": "ts-node workflow_tests/utils/preGenerateTest.ts",
"setup-https": "mkcert -install && mkcert -cert-file config/webpack/certificate.pem -key-file config/webpack/key.pem dev.new.expensify.com localhost 127.0.0.1",
"e2e-test-runner-build": "ncc build tests/e2e/testRunner.ts -o tests/e2e/dist/"
"e2e-test-runner-build": "ncc build tests/e2e/testRunner.ts -o tests/e2e/dist/",
"react-compiler-healthcheck": "react-compiler-healthcheck --verbose"
},
"dependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6",
Expand Down Expand Up @@ -253,7 +254,7 @@
"babel-jest": "29.4.1",
"babel-loader": "^9.1.3",
"babel-plugin-module-resolver": "^5.0.0",
"babel-plugin-react-compiler": "^0.0.0-experimental-c23de8d-20240515",
"babel-plugin-react-compiler": "0.0.0-experimental-696af53-20240625",
"babel-plugin-react-native-web": "^0.18.7",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-remove-console": "^6.9.4",
Expand All @@ -272,7 +273,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jsdoc": "^46.2.6",
"eslint-plugin-react-compiler": "^0.0.0-experimental-53bb89e-20240515",
"eslint-plugin-react-compiler": "0.0.0-experimental-0998c1e-20240625",
"eslint-plugin-react-native-a11y": "^3.3.0",
"eslint-plugin-storybook": "^0.8.0",
"eslint-plugin-testing-library": "^6.2.2",
Expand All @@ -289,6 +290,7 @@
"portfinder": "^1.0.28",
"prettier": "^2.8.8",
"pusher-js-mock": "^0.3.3",
"react-compiler-healthcheck": "^0.0.0-experimental-b130d5f-20240625",
"react-is": "^18.3.1",
"react-native-clean-project": "^4.0.0-alpha4.0",
"react-test-renderer": "18.2.0",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
diff --git a/node_modules/react-compiler-healthcheck/dist/index.js b/node_modules/react-compiler-healthcheck/dist/index.js
index b427385..4bf23db 100755
--- a/node_modules/react-compiler-healthcheck/dist/index.js
+++ b/node_modules/react-compiler-healthcheck/dist/index.js
@@ -69154,7 +69154,7 @@ var reactCompilerCheck = {
compile(source, path);
}
},
- report() {
+ report(verbose) {
const totalComponents =
SucessfulCompilation.length +
countUniqueLocInEvents(OtherFailures) +
@@ -69164,6 +69164,50 @@ var reactCompilerCheck = {
`Successfully compiled ${SucessfulCompilation.length} out of ${totalComponents} components.`
)
);
+
+ if (verbose) {
+ for (const compilation of [...SucessfulCompilation, ...ActionableFailures, ...OtherFailures]) {
+ const filename = compilation.fnLoc?.filename;
+
+ if (compilation.kind === "CompileSuccess") {
+ const name = compilation.fnName;
+ const isHook = name?.startsWith('use');
+
+ if (name) {
+ console.log(
+ chalk.green(
+ `Successfully compiled ${isHook ? "hook" : "component" } [${name}](${filename})`
+ )
+ );
+ } else {
+ console.log(chalk.green(`Successfully compiled ${compilation.fnLoc?.filename}`));
+ }
+ }
+
+ if (compilation.kind === "CompileError") {
+ const { reason, severity, loc } = compilation.detail;
+
+ const lnNo = loc.start?.line;
+ const colNo = loc.start?.column;
+
+ const isTodo = severity === ErrorSeverity.Todo;
+
+ console.log(
+ chalk[isTodo ? 'yellow' : 'red'](
+ `Failed to compile ${
+ filename
+ }${
+ lnNo !== undefined ? `:${lnNo}${
+ colNo !== undefined ? `:${colNo}` : ""
+ }.` : ""
+ }`
+ ),
+ chalk[isTodo ? 'yellow' : 'red'](reason? `Reason: ${reason}` : "")
+ );
+ console.log("\n");
+ }
+ }
+ }
},
};
const JsFileExtensionRE = /(js|ts|jsx|tsx)$/;
@@ -69200,9 +69244,16 @@ function main() {
type: "string",
default: "**/+(*.{js,mjs,jsx,ts,tsx}|package.json)",
})
+ .option('verbose', {
+ description: 'run with verbose logging',
+ type: 'boolean',
+ default: false,
+ alias: 'v',
+ })
.parseSync();
const spinner = ora("Checking").start();
let src = argv.src;
+ let verbose = argv.verbose;
const globOptions = {
onlyFiles: true,
ignore: [
@@ -69222,7 +69273,7 @@ function main() {
libraryCompatCheck.run(source, path);
}
spinner.stop();
- reactCompilerCheck.report();
+ reactCompilerCheck.report(verbose);
strictModeCheck.report();
libraryCompatCheck.report();
});
2 changes: 1 addition & 1 deletion src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function Expensify({
}
appStateChangeListener.current.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps -- we don't want this effect to run again
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps -- we don't want this effect to run again
}, []);

// This is being done since we want to play sound even when iOS device is on silent mode, to align with other platforms.
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddPlaidBankAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function AddPlaidBankAccount({
return unsubscribeToNavigationShortcuts;

// disabling this rule, as we want this to run only on the first render
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/AmountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function AmountForm(
setNewAmount(MoneyRequestUtils.stripDecimalsFromAmount(currentAmount));

// we want to update only when decimals change (setNewAmount also changes when decimals change).
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [decimals]);

/**
Expand Down
1 change: 1 addition & 0 deletions src/components/AnimatedStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function AnimatedStep({onAnimationEnd, direction = CONST.ANIMATION_DIRECTION.IN,
}}
duration={CONST.ANIMATED_TRANSITION}
animation={animationStyle}
// eslint-disable-next-line react-compiler/react-compiler
useNativeDriver={useNativeDriver}
style={style}
>
Expand Down
6 changes: 3 additions & 3 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function AttachmentModal({
}

setIsModalOpen(false);
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [isModalOpen, isConfirmButtonDisabled, onConfirm, file, sourceState]);

/**
Expand Down Expand Up @@ -367,7 +367,7 @@ function AttachmentModal({
onModalClose();
}

// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [onModalClose]);

/**
Expand Down Expand Up @@ -428,7 +428,7 @@ function AttachmentModal({
});
}
return menuItems;
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [isReceiptAttachment, transaction, file, sourceState, iouType]);

// There are a few things that shouldn't be set until we absolutely know if the file is a receipt or an attachment.
Expand Down
1 change: 1 addition & 0 deletions src/components/AttachmentPicker/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s
* @param onCanceledHandler A callback that will be called without a selected attachment
*/
const open = (onPickedHandler: (file: FileObject) => void, onCanceledHandler: () => void = () => {}) => {
// eslint-disable-next-line react-compiler/react-compiler
completeAttachmentSelection.current = onPickedHandler;
onCanceled.current = onCanceledHandler;
setIsVisible(true);
Expand Down
1 change: 1 addition & 0 deletions src/components/AttachmentPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function AttachmentPicker({children, type = CONST.ATTACHMENT_PICKER_TYPE.FILE}:

// Cleanup after selecting a file to start from a fresh state
if (fileInput.current) {
// eslint-disable-next-line react-compiler/react-compiler
fileInput.current.value = '';
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function AttachmentCarouselPager(
const pageScrollHandler = usePageScrollHandler((e) => {
'worklet';

// eslint-disable-next-line react-compiler/react-compiler
activePage.value = e.position;
isPagerScrolling.value = e.offset !== 0;
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source,
onNavigate(targetAttachments[initialPage]);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [reportActions, compareImage]);

/** Updates the page state when the user navigates between attachments */
Expand Down
2 changes: 1 addition & 1 deletion src/components/Attachments/AttachmentCarousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source,

scrollRef.current.scrollToIndex({index: page, animated: false});
// The hook is not supposed to run on page change, so we keep the page out of the dependencies
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [cellWidth]);

/** Updates the page state when the user navigates between attachments */
Expand Down
Loading

0 comments on commit fe2fcf0

Please sign in to comment.