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

Opt-in all @wordpress packages imports via DEWP #2055

Merged
merged 6 commits into from
Aug 15, 2023

Conversation

eason9487
Copy link
Member

@eason9487 eason9487 commented Aug 14, 2023

Changes proposed in this Pull Request:

It's the final part of #1833

To opt-in all @wordpress packages imports via DEWP and revert all gradually externalized @wordpress/components imports, this PR:

  • Remove the extracted/ prefix from all 'extracted/@wordpress/components' imports.
  • Opt-in @wordpress/components and @wordpress/compose to import from the external source of DEWP.
    • Remove them from the requestToExternal array in the webpack config. So that all their imports will be externalized via regular DEWP instead of the mechanism of extracted/ prefix.
    • The @wordpress/compose package was removed together as the following uses don't have external changes after @wordpress/compose 5.1.2 (used by WC 6.9):
      • createHigherOrderComponent
      • useFocusOutside: refactor to TypeScript
      • useInstanceId: refactor to TypeScript
      • useReducedMotion
      • useViewportMatch
      • Changelog
  • Remove a compatible workaround for DatePicker as it has been fixed since WC 7.2.
  • Rebalance the max size config of bundlewatch for each non-wildcard file to 1.2 times.
  • Update the .externalized.json file.
  • Revert "Prevent the "import/no-duplicates" warning for the externalization process". (see #1844)

Screenshots:

image

Detailed test instructions:

  1. Check if all build scripts, npm start, npm run dev, npm run start:hot and npm run build, can run successfully.
  2. Run bundle analyzer: npm run env -- NODE_ENV=production wp-scripts build --webpack-bundle-analyzer
    • Check if there is no DEWPable @wordpress/* package included in the build bundle.
    • P.S. @wordpress/icons is not a DEWPed package. Ref
  3. Search the codebase to check if there is no 'extracted/@wordpress/components' import.

Changelog entry

@eason9487 eason9487 requested a review from a team August 14, 2023 11:34
@eason9487 eason9487 self-assigned this Aug 14, 2023
@github-actions github-actions bot added the changelog: dev Developer-facing only change. label Aug 14, 2023
@tomalec tomalec self-requested a review August 14, 2023 16:00
@tomalec
Copy link
Member

tomalec commented Aug 14, 2023

Awsome, that's pretty heavy reduction in the bundle size :)

The @wordpress/compose package was removed together as the following uses don't have external changes after @wordpress/compose 5.1.2 (used by WC 6.9):

According to dewped our min WP 5.9 uses @wordpress/[email protected], but the lack of changes still applies.

Details

$ dewped pdep @wordpress/compose  --wpVersion=5.9 --wcVersion=6.9
 Name               WordPress 5.9 WooCommerce 6.9 Local   
 ────────────────── ───────────── ─────────────── ─────── 
 @wordpress/compose 5.0.7                         ^5.20.0 
$ dewped pdep @wordpress/compose  --wpVersion=6.0 --wcVersion=6.9
 Name               WordPress 6.0 WooCommerce 6.9 Local   
 ────────────────── ───────────── ─────────────── ─────── 
 @wordpress/compose 5.4.1                         ^5.20.0 
 $ dewped pdep @wordpress/compose  --wpVersion=6.1 --wcVersion=6.9
 Name               WordPress 6.1 WooCommerce 6.9 Local   
 ────────────────── ───────────── ─────────────── ─────── 
 @wordpress/compose 5.15.2                        ^5.20.0 
 $ dewped pdep @wordpress/compose  --wpVersion=6.2 --wcVersion=6.9
 Name               WordPress 6.2 WooCommerce 6.9 Local   
 ────────────────── ───────────── ─────────────── ─────── 
 @wordpress/compose 6.3.3                         ^5.20.0 
 $ dewped pdep @wordpress/compose  --wpVersion=6.3 --wcVersion=6.9
 Name               WordPress 6.3 WooCommerce 6.9 Local   
 ────────────────── ───────────── ─────────────── ─────── 
 @wordpress/compose 6.12.2                        ^5.20.0 

With WP L-1, we're safe for sure, it's 6.3.3.

Copy link
Member

@tomalec tomalec left a comment

Choose a reason for hiding this comment

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

I have reviewed the code & bundles and smoke-tested crucial flows. LGTM.

Base automatically changed from dev/1833-externalize-controls to dev/externalize-wp-packages August 15, 2023 03:15
@eason9487 eason9487 merged commit bf5269f into dev/externalize-wp-packages Aug 15, 2023
4 checks passed
@eason9487 eason9487 deleted the dev/1833-dewp-wp-packages branch August 15, 2023 03:21
@eason9487 eason9487 mentioned this pull request Aug 22, 2023
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: dev Developer-facing only change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants