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

Build: Use globalThis over process.env and enable TS lib checking #61486

Merged
merged 40 commits into from May 23, 2024

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented May 8, 2024

What?

There have been some problems with types in some packages. This resulted in build errors and in producing types that were not valid. This was observed in several other PRs recently.

This PR does two things:

  • Remove all skipLibCheck from tsconfig.
  • Update usage of custom process.env.NAME usage in the application to globalThis.NAME. This has the benefit of being safer in third party code and valid in the type system.

There are a few problems with using process.env, although it's common to use some names for historic reasons - primarily process.env.NODE_ENV.

  • It only exists in Node.js. It does not exist in the browser. This means that additional checks must be added in application code to make sure that it doesn't error. Using process.env in general is error prone.
  • process.env in Node.js is unusual. It's a key-value structure where the values are always strings. Gutenberg used non-string values which was wrong in environments where process.env existed, but also did compile-time replacement sometimes. This makes everything confusing.
  • The inconsistent process.env values caused problems in the type system. They conflicted with the Node.js types that correctly assert that process.env values must be strings.

Instead of using the problematic process.env "object" for these values, we change to use globalThis. This is the global object that works natively in both browsers and Node.js. It is an object and can be used as such, so assigning arbitrary properties is straightforward.

One big benefit is that globalThis is much easier to use, globalThis.nonExistentProperty is undefined instead of a ReferenceError like when trying to access process.env.nonExistentProperty in the browser.

This eliminates the type issues around using process.env and is generally more coherent. The build tooling and code using WordPress and Gutenberg variables around process.env has been updated in this PR. Documentation has also been updated where I found it.

Some eslint rules have also been added, changed, or removed:

  • @wordpress/wp-global-usage replaces @wordpress/is-gutenberg-plugin. It applies the same logic to all the globals that Gutenberg uses - namely that they should be used in simple conditional tests to help with dead code elimination in compiled packages.
  • @wordpress/wp-process-env is a new rule that makes the usage of process.env WordPress/Gutenberg variables a violation. It includes a fixer, so e.b. process.env.SCRIPT_DEBUG becomes globalThis.SCRIPT_DEBUG.
  • @wordpress/gutenberg-phase rule is removed - this variable has not been used for some time.

Related changes:

Why?

How?

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

@sirreal sirreal force-pushed the fix/skip-lib-check-breakage branch 2 times, most recently from ccb658c to 40c0fd7 Compare May 8, 2024 17:08
sirreal added a commit that referenced this pull request May 8, 2024
Squashed commit of the following:

commit 40c0fd7
Author: Jon Surrell <sirreal@users.noreply.github.com>
Date:   Wed May 8 18:55:56 2024 +0200

    Patch react-autosize-textarea for updated types

commit 69cf754
Author: Jon Surrell <sirreal@users.noreply.github.com>
Date:   Wed May 8 18:48:37 2024 +0200

    upgrade framer-motion

commit b383044
Author: Jon Surrell <sirreal@users.noreply.github.com>
Date:   Wed May 8 18:34:44 2024 +0200

    Upgrade @use-gesture/react

commit fdf93ae
Author: Jon Surrell <sirreal@users.noreply.github.com>
Date:   Wed May 8 18:32:11 2024 +0200

    Go bonkers on the global vars

commit cc43b8c
Author: Jon Surrell <sirreal@users.noreply.github.com>
Date:   Wed May 8 16:46:39 2024 +0200

    Fix the process problem

commit 548145e
Author: Jon Surrell <sirreal@users.noreply.github.com>
Date:   Wed May 8 13:33:23 2024 +0200

    No more skipLibCheck

commit 1eb7644
Author: Miguel Fonseca <150562+mcsf@users.noreply.github.com>
Date:   Wed May 8 16:33:10 2024 +0100

    build: Suggest workaround if `tsc --build` fails (#61501)

    Following the merge of #60796, developers may face build issues that
    require package types to be rebuilt. The problem is that `tsc --build`
    fails somewhat silently -- or rather, there is some output, but it's not
    clear in the console which stage of the `build:package-types` command
    failed, and hence what the workaround should be.

    This commit alleviates the issue by logging a helpful message in the
    console if `tsc --build` fails:

        tsc failed. Try cleaning up first: `npm run clean:package-types`

commit 14ecb1d
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed May 8 09:49:20 2024 -0400

    Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group (#61449)

    Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout).

    Updates `actions/checkout` from 4.1.4 to 4.1.5
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@0ad4b8f...44c2b7a)

    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: github-actions
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: desrosj <desrosj@git.wordpress.org>

commit e899475
Author: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
Date:   Wed May 8 16:48:50 2024 +0300

    RadioControl: Fix shrinking radio controls (#61476)

    Co-authored-by: tyxla <tyxla@git.wordpress.org>
    Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

commit 839c17d
Author: Riad Benguella <benguella@gmail.com>
Date:   Wed May 8 14:39:34 2024 +0100

    Editor: Unify Header component. (#61273)

    Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
    Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
    Co-authored-by: jeryj <jeryj@git.wordpress.org>
    Co-authored-by: jasmussen <joen@git.wordpress.org>

commit 2c2f899
Author: Ella <4710635+ellatrix@users.noreply.github.com>
Date:   Wed May 8 20:30:44 2024 +0900

    Revert "useBlockSync: remove isControlled effect" (#61480)

    Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
    Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Copy link

github-actions bot commented May 8, 2024

Size Change: 0 B

Total Size: 1.74 MB

ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 955 B
build/annotations/index.min.js 2.27 kB
build/api-fetch/index.min.js 2.32 kB
build/autop/index.min.js 2.1 kB
build/blob/index.min.js 578 B
build/block-directory/index.min.js 7.29 kB
build/block-directory/style-rtl.css 1.03 kB
build/block-directory/style.css 1.03 kB
build/block-editor/content-rtl.css 4.57 kB
build/block-editor/content.css 4.57 kB
build/block-editor/default-editor-styles-rtl.css 395 B
build/block-editor/default-editor-styles.css 395 B
build/block-editor/index.min.js 260 kB
build/block-editor/style-rtl.css 15.5 kB
build/block-editor/style.css 15.5 kB
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 133 B
build/block-library/blocks/audio/theme.css 133 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 277 B
build/block-library/blocks/block/editor.css 277 B
build/block-library/blocks/button/editor-rtl.css 415 B
build/block-library/blocks/button/editor.css 414 B
build/block-library/blocks/button/style-rtl.css 627 B
build/block-library/blocks/button/style.css 626 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 421 B
build/block-library/blocks/columns/style.css 421 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 671 B
build/block-library/blocks/cover/editor.css 674 B
build/block-library/blocks/cover/style-rtl.css 1.7 kB
build/block-library/blocks/cover/style.css 1.69 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 86 B
build/block-library/blocks/details/style.css 86 B
build/block-library/blocks/embed/editor-rtl.css 312 B
build/block-library/blocks/embed/editor.css 312 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 133 B
build/block-library/blocks/embed/theme.css 133 B
build/block-library/blocks/file/editor-rtl.css 326 B
build/block-library/blocks/file/editor.css 327 B
build/block-library/blocks/file/style-rtl.css 280 B
build/block-library/blocks/file/style.css 281 B
build/block-library/blocks/file/view.min.js 324 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/form-input/editor-rtl.css 227 B
build/block-library/blocks/form-input/editor.css 227 B
build/block-library/blocks/form-input/style-rtl.css 343 B
build/block-library/blocks/form-input/style.css 343 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 340 B
build/block-library/blocks/form-submission-notification/editor.css 340 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/form/view.min.js 471 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 956 B
build/block-library/blocks/gallery/editor.css 960 B
build/block-library/blocks/gallery/style-rtl.css 1.72 kB
build/block-library/blocks/gallery/style.css 1.72 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 B
build/block-library/blocks/group/editor-rtl.css 403 B
build/block-library/blocks/group/editor.css 403 B
build/block-library/blocks/group/style-rtl.css 103 B
build/block-library/blocks/group/style.css 103 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 336 B
build/block-library/blocks/html/editor.css 337 B
build/block-library/blocks/image/editor-rtl.css 891 B
build/block-library/blocks/image/editor.css 891 B
build/block-library/blocks/image/style-rtl.css 1.6 kB
build/block-library/blocks/image/style.css 1.59 kB
build/block-library/blocks/image/theme-rtl.css 133 B
build/block-library/blocks/image/theme.css 133 B
build/block-library/blocks/image/view.min.js 1.54 kB
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 494 B
build/block-library/blocks/latest-posts/style.css 494 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 306 B
build/block-library/blocks/media-text/editor.css 305 B
build/block-library/blocks/media-text/style-rtl.css 505 B
build/block-library/blocks/media-text/style.css 503 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 668 B
build/block-library/blocks/navigation-link/editor.css 669 B
build/block-library/blocks/navigation-link/style-rtl.css 193 B
build/block-library/blocks/navigation-link/style.css 192 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 296 B
build/block-library/blocks/navigation-submenu/editor.css 295 B
build/block-library/blocks/navigation/editor-rtl.css 2.26 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/style-rtl.css 2.26 kB
build/block-library/blocks/navigation/style.css 2.25 kB
build/block-library/blocks/navigation/view.min.js 1.03 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 377 B
build/block-library/blocks/page-list/editor.css 377 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-content/editor-rtl.css 74 B
build/block-library/blocks/post-content/editor.css 74 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 734 B
build/block-library/blocks/post-featured-image/editor.css 732 B
build/block-library/blocks/post-featured-image/style-rtl.css 342 B
build/block-library/blocks/post-featured-image/style.css 342 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 397 B
build/block-library/blocks/post-template/style.css 396 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 354 B
build/block-library/blocks/pullquote/style.css 353 B
build/block-library/blocks/pullquote/theme-rtl.css 174 B
build/block-library/blocks/pullquote/theme.css 174 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/view.min.js 958 B
build/block-library/blocks/quote/style-rtl.css 237 B
build/block-library/blocks/quote/style.css 237 B
build/block-library/blocks/quote/theme-rtl.css 233 B
build/block-library/blocks/quote/theme.css 235 B
build/block-library/blocks/read-more/style-rtl.css 140 B
build/block-library/blocks/read-more/style.css 140 B
build/block-library/blocks/rss/editor-rtl.css 101 B
build/block-library/blocks/rss/editor.css 101 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 184 B
build/block-library/blocks/search/editor.css 184 B
build/block-library/blocks/search/style-rtl.css 690 B
build/block-library/blocks/search/style.css 689 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 478 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 239 B
build/block-library/blocks/separator/style.css 239 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 286 B
build/block-library/blocks/shortcode/editor.css 286 B
build/block-library/blocks/site-logo/editor-rtl.css 805 B
build/block-library/blocks/site-logo/editor.css 805 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 324 B
build/block-library/blocks/social-link/editor.css 324 B
build/block-library/blocks/social-links/editor-rtl.css 676 B
build/block-library/blocks/social-links/editor.css 675 B
build/block-library/blocks/social-links/style-rtl.css 1.5 kB
build/block-library/blocks/social-links/style.css 1.5 kB
build/block-library/blocks/spacer/editor-rtl.css 350 B
build/block-library/blocks/spacer/editor.css 350 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 395 B
build/block-library/blocks/table/editor.css 395 B
build/block-library/blocks/table/style-rtl.css 639 B
build/block-library/blocks/table/style.css 639 B
build/block-library/blocks/table/theme-rtl.css 152 B
build/block-library/blocks/table/theme.css 152 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 393 B
build/block-library/blocks/template-part/editor.css 393 B
build/block-library/blocks/template-part/theme-rtl.css 107 B
build/block-library/blocks/template-part/theme.css 107 B
build/block-library/blocks/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 185 B
build/block-library/blocks/video/style.css 185 B
build/block-library/blocks/video/theme-rtl.css 133 B
build/block-library/blocks/video/theme.css 133 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.2 kB
build/block-library/editor.css 12.2 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/index.min.js 218 kB
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/style-rtl.css 14.8 kB
build/block-library/style.css 14.8 kB
build/block-library/theme-rtl.css 707 B
build/block-library/theme.css 713 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 51.8 kB
build/commands/index.min.js 15.2 kB
build/commands/style-rtl.css 953 B
build/commands/style.css 951 B
build/components/index.min.js 222 kB
build/components/style-rtl.css 12 kB
build/components/style.css 12 kB
build/compose/index.min.js 12.8 kB
build/core-commands/index.min.js 2.71 kB
build/core-data/index.min.js 72.5 kB
build/customize-widgets/index.min.js 10.9 kB
build/customize-widgets/style-rtl.css 1.36 kB
build/customize-widgets/style.css 1.36 kB
build/data-controls/index.min.js 640 B
build/data/index.min.js 9.01 kB
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 451 B
build/dom-ready/index.min.js 324 B
build/dom/index.min.js 4.65 kB
build/edit-post/classic-rtl.css 578 B
build/edit-post/classic.css 578 B
build/edit-post/index.min.js 14.6 kB
build/edit-post/style-rtl.css 2.68 kB
build/edit-post/style.css 2.68 kB
build/edit-site/index.min.js 214 kB
build/edit-site/style-rtl.css 12.5 kB
build/edit-site/style.css 12.5 kB
build/edit-widgets/index.min.js 17.5 kB
build/edit-widgets/style-rtl.css 4.18 kB
build/edit-widgets/style.css 4.18 kB
build/editor/index.min.js 91.8 kB
build/editor/style-rtl.css 8.39 kB
build/editor/style.css 8.4 kB
build/element/index.min.js 4.83 kB
build/escape-html/index.min.js 537 B
build/format-library/index.min.js 8.09 kB
build/format-library/style-rtl.css 493 B
build/format-library/style.css 492 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 448 B
build/i18n/index.min.js 3.58 kB
build/interactivity/debug.min.js 16.4 kB
build/interactivity/file.min.js 447 B
build/interactivity/image.min.js 1.67 kB
build/interactivity/index.min.js 13.2 kB
build/interactivity/navigation.min.js 1.17 kB
build/interactivity/query.min.js 740 B
build/interactivity/router.min.js 2.81 kB
build/interactivity/search.min.js 618 B
build/is-shallow-equal/index.min.js 527 B
build/keyboard-shortcuts/index.min.js 1.31 kB
build/keycodes/index.min.js 1.46 kB
build/list-reusable-blocks/index.min.js 2.14 kB
build/list-reusable-blocks/style-rtl.css 851 B
build/list-reusable-blocks/style.css 851 B
build/media-utils/index.min.js 2.92 kB
build/modules/importmap-polyfill.min.js 12.2 kB
build/notices/index.min.js 948 B
build/nux/index.min.js 1.58 kB
build/nux/style-rtl.css 748 B
build/nux/style.css 744 B
build/patterns/index.min.js 6.51 kB
build/patterns/style-rtl.css 595 B
build/patterns/style.css 595 B
build/plugins/index.min.js 1.81 kB
build/preferences-persistence/index.min.js 2.06 kB
build/preferences/index.min.js 2.9 kB
build/preferences/style-rtl.css 710 B
build/preferences/style.css 712 B
build/primitives/index.min.js 831 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 1 kB
build/react-i18n/index.min.js 629 B
build/react-refresh-entry/index.min.js 9.47 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.7 kB
build/reusable-blocks/index.min.js 2.72 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.1 kB
build/router/index.min.js 1.96 kB
build/server-side-render/index.min.js 1.97 kB
build/shortcode/index.min.js 1.39 kB
build/style-engine/index.min.js 2.02 kB
build/token-list/index.min.js 582 B
build/url/index.min.js 3.74 kB
build/vendors/react-dom.min.js 42.8 kB
build/vendors/react-jsx-runtime.min.js 554 B
build/vendors/react.min.js 2.65 kB
build/viewport/index.min.js 964 B
build/warning/index.min.js 249 B
build/widgets/index.min.js 7.13 kB
build/widgets/style-rtl.css 1.17 kB
build/widgets/style.css 1.17 kB
build/wordcount/index.min.js 1.02 kB

compressed-size-action

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

I like the direction. Thank you for taking care of the additional refactoring for the special constants we use to guard some features like IS_GUTENBERG_PLUGIN, IS_WORDPRESS_CORE and SCRIPT_DEBUG.

One file still needs to get updated:

https://github.com/WordPress/gutenberg/blob/trunk/test/unit/config/gutenberg-env.js

If I follow it correctly, it sets the default values for unit tests, now it should be set on globalThis.*.

packages/interactivity/src/directives.js Outdated Show resolved Hide resolved
patches/react-autosize-textarea+7.1.0.patch Outdated Show resolved Hide resolved
@@ -64,13 +64,15 @@ const plugins = [
process.env.WP_BUNDLE_ANALYZER && new BundleAnalyzerPlugin(),
new DefinePlugin( {
// Inject the `IS_GUTENBERG_PLUGIN` global, used for feature flagging.
'process.env.IS_GUTENBERG_PLUGIN':
process.env.npm_package_config_IS_GUTENBERG_PLUGIN,
'globalThis.IS_GUTENBERG_PLUGIN': JSON.stringify(
Copy link
Member

Choose a reason for hiding this comment

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

I like the direction. We will have to remember to update the WordPress Core so tree-shaking continues to work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the "php backport" label. Although it's not really PHP :)

Copy link
Member

Choose a reason for hiding this comment

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

What is to be backported? Is this file shared with core?

Copy link
Contributor

Choose a reason for hiding this comment

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

The webpack config change.

Copy link
Member Author

Choose a reason for hiding this comment

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

It would be a very small and simple (but important!) change. I'll open a PR for that soon so it's ready.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sirreal
Copy link
Member Author

sirreal commented May 10, 2024

I like the direction. Thank you for taking care of the additional refactoring for the special constants we use to guard some features like IS_GUTENBERG_PLUGIN, IS_WORDPRESS_CORE and SCRIPT_DEBUG.

Thanks! I agree, I think this will be easier to work with 👍

One file still needs to get updated:

Good spot! Maybe we should also switch the global global to be globalThis.

@youknowriad youknowriad added the Needs PHP backport Needs PHP backport to Core label May 10, 2024
@sirreal
Copy link
Member Author

sirreal commented May 10, 2024

There are several eslint rules around how to use process.env.[OUR_VARIABLES]. They probably need to be updated to ban those variables (maybe autofix them to the globalThis… versions) and warn in the same cases (usage outside of conditionals):

Literal( node ) {
// Bypass any identifiers with a node value different to `IS_GUTENBERG_PLUGIN`.
if ( node.value !== 'IS_GUTENBERG_PLUGIN' ) {
return;
}

Literal( node ) {
// Bypass any identifiers with a node value different to `GUTENBERG_PHASE`.
if ( node.value !== 'GUTENBERG_PHASE' ) {
return;
}
if ( node.parent && node.parent.type === 'MemberExpression' ) {
testIsAccessedViaProcessEnv( node, context );
}
},
};

(Maybe GUTENBERG_PHASE needs to be removed or updated to simply ban the variable?)

@sirreal
Copy link
Member Author

sirreal commented May 10, 2024

Docs need an update:

## Introducing `process.env.IS_GUTENBERG_PLUGIN`

@sirreal sirreal force-pushed the fix/skip-lib-check-breakage branch 6 times, most recently from e1b077e to b33d096 Compare May 13, 2024 15:39
@sirreal sirreal force-pushed the fix/skip-lib-check-breakage branch from b33d096 to 3980ff3 Compare May 13, 2024 19:59
@sirreal
Copy link
Member Author

sirreal commented May 13, 2024

This should have breaking change changelog for all the updated packages- maybe for all packages- mentioning the change to globalThis.

### Breaking Changes

- `@wordpress/is-gutenberg-plugin` rule has been replaced by `@wordpress/wp-global-usage` ([#61486](https://github.com/WordPress/gutenberg/pull/61486)).
- `@wordpress/wp-process-env` rule has been added and included in the recommended configurations ([#61486](https://github.com/WordPress/gutenberg/pull/61486)).
Copy link
Member Author

Choose a reason for hiding this comment

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

@wordpress/gutenberg-phase rule removed. That doesn't exist and hasn't been used for some time.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it stopped being a thing after WordPress Phase 2 was concluded - sometime between WP 5.9 and 6.3 when site editor was going out of beta.

@sirreal sirreal force-pushed the fix/skip-lib-check-breakage branch from 86561d4 to 926ab27 Compare May 23, 2024 09:45
@sirreal sirreal enabled auto-merge (squash) May 23, 2024 10:10
@sirreal sirreal merged commit ed7d786 into trunk May 23, 2024
63 checks passed
@sirreal sirreal deleted the fix/skip-lib-check-breakage branch May 23, 2024 10:20
@github-actions github-actions bot added this to the Gutenberg 18.5 milestone May 23, 2024
@sirreal sirreal added Needs Dev Note Requires a developer note for a major WordPress release cycle and removed Needs Dev Note Requires a developer note for a major WordPress release cycle labels May 23, 2024
@sirreal
Copy link
Member Author

sirreal commented May 23, 2024

I added and removed the dev note label. Dev notes are largely for WordPress developers and these changes should not affect them at all. They'll be using the included Scripts from WordPress that already have the optimizations applied.

This change already includes breaking change changelogs for folks consuming the packages on npm, that's probably the best place for it.

@Mamaduka
Copy link
Member

@sirreal, I see the following error in the editor after this got merged. Is there an additional step to get it fixed?

Screenshot

CleanShot 2024-05-23 at 20 01 09

@sirreal
Copy link
Member Author

sirreal commented May 23, 2024

@Mamaduka I think that's probably a stale process or something. Try running npm ci and restarting the linter process or your editor. I'm not able to reproduce any issue with the new lint rules in the repo.

@Mamaduka
Copy link
Member

Thanks, @sirreal! The npm ci did the trick.

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request May 24, 2024
This updates the build to account for related changes in WordPress packages. More details in WordPress/gutenberg#61486.

Props jonsurrell, youknowriad, swissspidy, gziolo.
Fixes #61262.




git-svn-id: https://develop.svn.wordpress.org/trunk@58193 602fd350-edb4-49c9-b593-d223f7449a82
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request May 24, 2024
This updates the build to account for related changes in WordPress packages. More details in WordPress/gutenberg#61486.

Props jonsurrell, youknowriad, swissspidy, gziolo.
Fixes #61262.



Built from https://develop.svn.wordpress.org/trunk@58193


git-svn-id: https://core.svn.wordpress.org/trunk@57656 1a063a9b-81f0-0310-95a4-ce76da25c4cd
markjaquith pushed a commit to WordPress/WordPress that referenced this pull request May 24, 2024
This updates the build to account for related changes in WordPress packages. More details in WordPress/gutenberg#61486.

Props jonsurrell, youknowriad, swissspidy, gziolo.
Fixes #61262.



Built from https://develop.svn.wordpress.org/trunk@58193


git-svn-id: http://core.svn.wordpress.org/trunk@57656 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs PHP backport Needs PHP backport to Core [Package] Scripts /packages/scripts [Type] Breaking Change For PRs that introduce a change that will break existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants