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

Integrate React Compiler #13826

Merged
merged 42 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9dccaa9
Follow naming conventions for refs
swissspidy Oct 22, 2024
1e26606
Storybook: Wrap reset in effect
swissspidy Oct 22, 2024
8292419
Block: fix `useViewportMatch` usage
swissspidy Oct 22, 2024
046d2a5
API Provider: use new var
swissspidy Oct 22, 2024
9254d83
Media reducer: use new var
swissspidy Oct 22, 2024
de9de69
Do not modify var outside hook
swissspidy Oct 22, 2024
f2a3f45
Install React Compiler
swissspidy Oct 22, 2024
16319d7
Hardening for React Compiler
swissspidy Oct 22, 2024
aa26974
Webpack: prevent source map warning
swissspidy Oct 22, 2024
648d8f8
Inline in jsx
swissspidy Oct 22, 2024
e581e9d
Move up Babel plugin
swissspidy Oct 24, 2024
7fcc0f1
Update react-compiler-runtime
swissspidy Oct 25, 2024
b4d2b25
Prettier fix
swissspidy Oct 25, 2024
14bb65c
Remove some unused variables
swissspidy Oct 25, 2024
0487558
Rename some refs
swissspidy Oct 25, 2024
df87fab
Merge branch 'main' into try/react-compiler
swissspidy Oct 25, 2024
11e1d49
Merge branch 'main' into try/react-compiler
swissspidy Oct 25, 2024
d4a47b8
Lint fix
swissspidy Oct 25, 2024
3ce406f
Fix some null refs
swissspidy Oct 25, 2024
30c108b
Fix media3p attribution component
swissspidy Oct 25, 2024
284eebb
Fix checkbox `id` attribute not matching the label's `for`
swissspidy Oct 25, 2024
edc1505
Fix proptypes warning
swissspidy Oct 25, 2024
4955c23
Fix text sets panel missing
swissspidy Oct 25, 2024
24b1e78
Update oxlint config
swissspidy Oct 25, 2024
41bdc9f
Use `renderHook` in hook unit test
swissspidy Oct 26, 2024
76617cf
Don't use effect in `TermsDialog`
swissspidy Oct 26, 2024
cc81564
Use named import
swissspidy Oct 26, 2024
88f96d8
Use same version for all
swissspidy Oct 26, 2024
66b168d
Silence some warnings.
swissspidy Oct 26, 2024
0efe41d
Merge branch 'main' into try/react-compiler
swissspidy Oct 26, 2024
eee2b26
Merge branch 'main' into try/react-compiler
swissspidy Oct 27, 2024
17a5dcf
Merge branch 'main' into try/react-compiler
swissspidy Nov 7, 2024
683e8bb
Merge branch 'main' into try/react-compiler
swissspidy Nov 24, 2024
022dbec
Merge branch 'main' into try/react-compiler
swissspidy Dec 5, 2024
795cf88
Merge branch 'main' into try/react-compiler
swissspidy Jan 6, 2025
f4a71b9
Fix another `null` issue in `useVideoTrimMode`
swissspidy Jan 6, 2025
05e2693
Fix a couple more issues
swissspidy Jan 7, 2025
619f4d1
Lint fix
swissspidy Jan 7, 2025
1500f2a
Merge branch 'main' into try/react-compiler
swissspidy Jan 9, 2025
5b2cfef
Merge branch 'main' into try/react-compiler
swissspidy Jan 9, 2025
b926938
Increase count in tab util
swissspidy Jan 9, 2025
b7eae28
Add sleep
swissspidy Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ web-stories-scraper
.npmpackagejsonlintrc.json
.npmrc
.nvmrc
.oxlintrc.json
.phpstorm.config.js
.phpstorm.meta.php
.phpunit.result.cache
Expand Down
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"jsx-a11y",
"markdown",
"react",
"react-compiler",
"react-hooks",
"styled-components-a11y"
],
Expand Down Expand Up @@ -214,6 +215,15 @@
"react/no-unused-prop-types": "error",
"react/react-in-jsx-scope": "off",
"react/self-closing-comp": "error",
"react-compiler/react-compiler": [
"error",
{
"environment": {
"enableTreatRefLikeIdentifiersAsRefs": true,
"validateRefAccessDuringRender": false
}
}
],
"import/no-extraneous-dependencies": "error",
"import/no-unresolved": "error",
"import/order": [
Expand Down Expand Up @@ -422,6 +432,7 @@
"rules": {
"@eslint-community/eslint-comments/require-description": "off",
"react/prop-types": "off",
"react-compiler/react-compiler": "off",
"jest/no-hooks": "off",
"jest/no-untyped-mock-factory": "off",
"jest/max-expects": "off",
Expand Down
13 changes: 13 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"settings": {
"jsdoc": {
"tagNamePreference": {
"returns": "return",
"yields": "yield"
}
}
},
"rules": {
"no-unused-vars": "off"
}
}
12 changes: 7 additions & 5 deletions .storybook/stories/playground/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* External dependencies
*/
import { useRef } from 'react';
import { useRef, useEffect } from 'react';
import { toId } from '@storybook/csf';
import { Dashboard, InterfaceSkeleton } from '@googleforcreators/dashboard';

Expand Down Expand Up @@ -102,10 +102,12 @@ const getAuthors = () => Promise.resolve([{ name: 'Author', id: 1 }]);
const useClearHash = () => {
const isHashCleaned = useRef(false);

if (!isHashCleaned.current) {
window.location.hash = '/';
isHashCleaned.current = true;
}
useEffect(() => {
if (!isHashCleaned.current) {
window.location.hash = '/';
isHashCleaned.current = true;
}
}, []);
};

export const _default = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function PreviewButton() {
</script>`
);
}
} catch (e) {
} catch {
// Not interested in the error.
}
};
Expand Down
1 change: 1 addition & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = function (api) {
'@babel/preset-typescript',
],
plugins: [
['babel-plugin-react-compiler', { target: '17' }],
'@wordpress/babel-plugin-import-jsx-pragma',
[
'babel-plugin-styled-components',
Expand Down
92 changes: 92 additions & 0 deletions package-lock.json

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

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"ajv-formats": "^3.0.1",
"babel-jest": "^29.6.1",
"babel-loader": "^9.2.1",
"babel-plugin-react-compiler": "0.0.0-experimental-63cca73-20250106",
"babel-plugin-styled-components": "^2.1.4",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"browserslist": "^4.24.4",
Expand All @@ -124,6 +125,7 @@
"eslint-plugin-oxlint": "^0.15.5",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.3",
"eslint-plugin-react-compiler": "0.0.0-experimental-63cca73-20250106",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-security": "^3.0.1",
"eslint-plugin-styled-components-a11y": "^2.2.0",
Expand Down Expand Up @@ -159,6 +161,7 @@
"postcss-syntax": "^0.36.2",
"prettier": "^3.4.2",
"puppeteer": "^23.11.1",
"react-compiler-runtime": "0.0.0-experimental-63cca73-20250106",
"react-refresh": "^0.16.0",
"react-test-renderer": "^17.0.2",
"rollup": "^2.79.2",
Expand Down Expand Up @@ -221,9 +224,9 @@
"lint:css:js:fix": "stylelint \"**/*.js\" --fix",
"lint:css:css": "stylelint \"**/*.css\"",
"lint:css:css:fix": "stylelint \"**/*.css\" --fix",
"lint:js": "oxlint && eslint .",
"lint:js:fix": "oxlint --fix && eslint --fix .",
"lint:js:report": "oxlint && eslint --output-file build/lint-js-report.json --format json .",
"lint:js": "oxlint -c=.oxlintrc.json --tsconfig=tsconfig.json --ignore-pattern=@types --react-perf-plugin && eslint .",
"lint:js:fix": "oxlint --fix -c=.oxlintrc.json --tsconfig=tsconfig.json --ignore-pattern=@types --react-perf-plugin && eslint --fix .",
"lint:js:report": "oxlint -c=.oxlintrc.json --tsconfig=tsconfig.json --ignore-pattern=@types --react-perf-plugin && eslint --output-file build/lint-js-report.json --format json .",
"lint:package-json": "npmPkgJsonLint .",
"lint:php": "composer phpcs",
"lint:php:fix": "composer phpcbf",
Expand Down
8 changes: 4 additions & 4 deletions packages/dashboard/src/app/api/useStoryApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ const useStoryApi = () => {
const [state, dispatch] = useReducer(storyReducer, defaultStoriesState);
const { apiCallbacks } = useConfig();

const isMounted = useRef(false);
const isMountedRef = useRef(false);

useEffect(() => {
isMounted.current = true;
isMountedRef.current = true;

return () => {
isMounted.current = false;
isMountedRef.current = false;
};
}, []);

Expand All @@ -78,7 +78,7 @@ const useStoryApi = () => {
const { stories, fetchedStoryIds, totalPages, totalStoriesByStatus } =
await apiCallbacks.fetchStories(queryParams);

if (!isMounted.current) {
if (!isMountedRef.current) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
const { isRTL, apiCallbacks } = useConfig();
const containerRef = useRef();
const gridRef = useRef();
const itemRefs = useRef({});
const itemsRef = useRef({});
const [activeGridItemId, setActiveGridItemId] = useState(null);
const { handleDetailsToggle, createStoryFromTemplate } =
templateActions || {};
Expand All @@ -58,7 +58,7 @@
useGridViewKeys({
containerRef,
gridRef,
itemRefs,
itemRefs: itemsRef,
isRTL,
currentItemId: activeGridItemId,
items: filteredTemplates,
Expand All @@ -69,7 +69,7 @@
// for legibility, it's based on the FOCUS_TEMPLATE_CLASS
useEffect(() => {
if (activeGridItemId) {
itemRefs.current?.[activeGridItemId]
itemsRef.current?.[activeGridItemId]

Check warning on line 72 in packages/dashboard/src/app/views/exploreTemplates/content/templateGridView.js

View check run for this annotation

Codecov / codecov/patch

packages/dashboard/src/app/views/exploreTemplates/content/templateGridView.js#L72

Added line #L72 was not covered by tests
?.querySelector(`.${FOCUS_TEMPLATE_CLASS}`)
?.focus();
}
Expand Down Expand Up @@ -97,7 +97,7 @@
key={slug}
posterSrc={posterSrc}
ref={(el) => {
itemRefs.current[id] = el;
itemsRef.current[id] = el;
}}
slug={slug}
status={status}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function StoriesView({ loading, storyActions, stories, view }) {
const handleOnDeleteStory = useCallback(() => {
trackEvent('delete_story');
storyActions.trashStory(activeStory);
setFocusedStory({ id: activeStory.id, isDeleted: true });
setFocusedStory({ id: activeStory?.id, isDeleted: true });
setActiveDialog('');
}, [storyActions, activeStory]);

Expand Down Expand Up @@ -162,6 +162,11 @@ function StoriesView({ loading, storyActions, stories, view }) {
[showSnackbar]
);

const handleCloseConfirmDialog = useCallback(() => {
setFocusedStory({ id: activeStory?.id });
setActiveDialog('');
}, [activeStory]);

const menuItems = STORY_CONTEXT_MENU_ITEMS.map((item) => {
switch (item?.value) {
case STORY_CONTEXT_MENU_ACTIONS.COPY_STORY_LINK:
Expand Down Expand Up @@ -257,10 +262,7 @@ function StoriesView({ loading, storyActions, stories, view }) {
isOpen
contentLabel={__('Dialog to confirm deleting a story', 'web-stories')}
title={__('Delete Story', 'web-stories')}
onClose={() => {
setFocusedStory({ id: activeStory.id });
setActiveDialog('');
}}
onClose={handleCloseConfirmDialog}
secondaryText={__('Cancel', 'web-stories')}
secondaryRest={{
['aria-label']: sprintf(
Expand Down
Loading
Loading