Skip to content

Conversation

@manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented Dec 16, 2025

An alternative to #46302 with preservation of git history

Social Previews package is used more in Jetpack than in Calypso - See pdWQjU-1uF-p2

Closes SOCIAL-268

Proposed changes:

  • Move over @automattic/social-previews package from Calypso with git history

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

renovate bot and others added 30 commits August 6, 2020 09:35
* fix(deps): update babel monorepo

* Dedupe @babel scope

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Sergio Cinos <[email protected]>
)

* Move Domain to the top of the preview

* Fix linter complaint

* Ensure text content stays within body boundaries

* Add ellipsis to long domains

* Ensure title wraps for very long words

* Remove box shadow around preview area

* Change description color

* Update title font size and line height

* Update text font family

* Update URL & description font size and line height

* Article: Clamp description after one line

* Add background and border

* Update border of image placeholder

* Update background color of image placeholder

* Apply border to preview image and placeholder alike
* Truncate description for improved a11y

* Visually clamp description after two lines

* Increase border radius

* Combine shared styles

* Visually clamp description after three lines for small summary preview

* Update tests to reflect changes
* Social Previews: fix twitter social preview overflow

* Social Previews: version bump

* Social Previews: add max-width to preview-area

Co-authored-by: cpap <[email protected]>
#45613
* Enables linting inside markdown blocks tagged as `js` or `javascript` 
* Disables some code style rules inside markdown code blocks to allow simpler examples
* Apply automatic eslint fixes for JS blocks in markdown files
* Manually fix code broken by eslint autofixer

#45639
* Enable remark rule 'no-literal-urls' and fix existing violations of this rule

#45644
* Enable remark rule 'heading-increments' and fix existing violations of this rule

#45645
* Enable remark rule 'no-heading-punctuation' and fix existing violations of this rule
* Adds capacity to disable rules using comments

Co-authored-by: Sara Marcondes <[email protected]>
* Disable some lint rules for codeblocks in markdown files

* [markdown] Fix lint errors in `apps/notifications` (#45803)
* [markdown] Fix lint errors in `client` (#45804)
* [markdown] Fix lint errors in `packages/babel-plugin-transform-wpcalypso-async` (#45805)
* [markdown] Fix lint errors in `packages/calypso-color-schemes` (#45807)
* [markdown] Fix lint errors in `packages/calypso-polyfills` (#45808)
* [markdown] Fix lint errors in `packages/components` (#45809)
* [markdown] Fix lint errors in `packages/data-stores` (#45810)
* [markdown] Fix lint errors in `packages/eslint-plugin-wpcalypso` (#45811)
* [markdown] Fix lint errors in `packages/i18n-calypso` (#45812)
* [markdown] Fix lint errors in `packages/i18n-calypso-cli` (#45813)
* [markdown] Fix lint errors in `packages/material-design-icons` (#45814)
* [markdown] Fix lint errors in `packages/media-library` (#45815)
* [markdown] Fix lint errors in `packages/photon` (#45816)
* [markdown] Fix lint errors in `packages/popup-monitor` (#45817)
* [markdown] Fix lint errors in `packages/react-i18n` (#45818)
* [markdown] Fix lint errors in `packages/request-external-access` (#45819)
* [markdown] Fix lint errors in `packages/social-previews` (#45820)
* [markdown] Fix lint errors in `packages/viewport` (#45821)
* [markdown] Fix lint errors in `packages/viewport-react` (#45822)
* [markdown] Fix lint errors in `packages/webpack-extensive-lodash-replacement-plugin` (#45823)
* [markdown] Fix lint errors in `packages/webpack-inline-constant-exports-plugin` (#45824)
* [markdown] Fix lint errors in `packages/wpcom.js` (#45825)
* [markdown] Fix lint errors in `packages/wpcom-proxy-request` (#45826)
* [markdown] Fix lint errors in `packages/calypso-build` (#45806)
…es (#45953)

* Ebables rule `import/no-extraneous-dependencies` for all packages

* Configure exceptions for import/no-extraneous-dependencies

* Adds missing dependencies
* Re-introduce calypso:main

* Adds missing resolver to jest config

* Change composite-checkout's webpack config to support calypso:src

* Bundle packages in the monorepo to

* Simplify resolver

* Delete redundant packagesInMonorepo
* Re-introduce calypso:main

* Bundle packages in the monorepo to

* Create a preset for jest

* Use the new jest-preset also for packages/shopping-cart

* Fix bad merge

Co-authored-by: Jarda Snajdr <[email protected]>
* fix(deps): update babel monorepo
* Force `evergreen` to include browsers that don't support optional chaining to avoid problems with webpack 4
* Drop direct import of @storybook/preset-typescript

Co-authored-by: Sergio Cinos <[email protected]>
* Deduplicate eslint-plugin-react-hooks (#48861)

* Deduplicate eslint-scope (#48862)

* Fix dependencies of eslint-plugin-wpcalypso (#48858)

* Add devDependency to eslint

* Update yarn.lock

* Deduplicate es-abstract (#48860)

* Deduplicate es-abstract

* Deduplicate es-abstract

* Clean up yarn.lock

* Adds missing dependencies (#48916)

* Update lodash to 4.17.20 (#48908)

* Update lodash to 4.17.20

* Update yarn.lock

* Update chromedrvier to 87.0.5 (#48905)
* fix(deps): update wordpress monorepo

* Use new colors

* Tests: update names of internal data control types

* Tests: fix selector resolution tests by waiting for one more state update

* Fix SftpCard tests by mocking window.matchMedia

* Type with hooks

* Fix Editing Toolkit build

* Remove types/wordpress packages

* Fix incorrect usage of i18n context in Gutenboarding

* Use original colors where the color modifications were too disruptive

* Restore __experimentalMainDashboardButton in expermental features e2e tests

* FSE: add type definitions for @wordpress/edit-post module

* Final yarn.lock update

* e2e: remove test for edit-site as we're testing on edit-post page

* Gutenboarding: use granular selectors from onboarding store

* Disable the Gutenboarding e2e test

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Sergio Cinos <[email protected]>
Co-authored-by: Jon Surrell <[email protected]>
Co-authored-by: Marko Andrijasevic <[email protected]>
* Update to webpack 5

* Clean up yarn.lock changes

* ExternalModulesWriter: descend into concatenated modules when searching for externals

Co-authored-by: Jarda Snajdr <[email protected]>
…encies (#50516)

* Add missing dev dependencies

* Add missing newline
* chore(deps): update dependency webpack to ^5.24.4


Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Sergio Cinos <[email protected]>
* fix(deps): update lodash monorepo to ^4.17.21


Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Sergio Cinos <[email protected]>
* fix(deps): update babel monorepo
* Deduplicate packages

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Sergio Cinos <[email protected]>
* fix(deps): update wordpress monorepo

* Fix test environment for window origin

* Fix eslint config

* Fix lint error related to _blank + rel

* Add dependency on jest-environment-jsdom

* Add COMPONENT_SYSTEM_PHASE to reduce bundle size

* Update wp-env to v4

* Bust GH actions cache

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: sarayourfriend <[email protected]>
Co-authored-by: Sergio Cinos <[email protected]>
…fication (#51295)

* Move css minification from WebpackRTLPlugin to calypso-build
* Prepare release of @automattic/webpack-rtl-plugin
* Prepare release of @automattic/calypso-build 8.0.0
…CSS minification (#51295)" (#51449)

This reverts commit ec4fac8.
* Bring back "build: Simplify WebpackRTLPlugin, use CssMinimizerPlugin for CSS minification (#51295)"

This reverts commit 8c7191e.

* Add rtl files to the chunk tree so they can be picked by assets-writer
* chore(deps): update dependency webpack to ^5.30.0

* Update snapshots

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Sergio Cinos <[email protected]>
Ensures that the "Social Previews" feature wraps text properly for Twitter
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the add/social-previews-package-with-history branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/social-previews-package-with-history
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/social-previews-package-with-history

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] Publicize Now Jetpack Social, auto-sharing [JS Package] Publicize Components [JS Package] Social Previews [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests Docs RNA labels Dec 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: January 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@manzoorwanijk
Copy link
Member Author

manzoorwanijk commented Dec 16, 2025

Since we want to do a regular git merge here, instead of a squash merge, I wonder if I should squash my commits I added after the git migration. 🤔

Or should I extract those extra changes to a new branch based off of this one and then merge that in a single commit?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the @automattic/social-previews package from Calypso to the Jetpack monorepo with preserved git history. The package provides React components for previewing social media posts across various platforms (Facebook, Twitter, LinkedIn, Instagram, Mastodon, Nextdoor, Threads, Tumblr, Bluesky, and Google Search).

Key Changes

  • Updated dependency reference from external npm package to workspace package
  • Added build configuration (tsup, TypeScript, Jest) for monorepo integration
  • Migrated comprehensive test suite with 657 test cases
  • Preserved complete source code including helpers, types, and platform-specific preview components

Reviewed changes

Copilot reviewed 160 out of 162 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/plugins/jetpack/package.json Updated dependency from external npm to workspace package
projects/plugins/jetpack/changelog/add-social-previews-package Added changelog entry for the migration
projects/js-packages/social-previews/tsup.config.ts Build configuration using tsup with SASS support
projects/js-packages/social-previews/tsconfig.json TypeScript configuration extending jetpack-js-tools
projects/js-packages/social-previews/tests/jest.config.cjs Jest test configuration with jsdom environment
projects/js-packages/social-previews/tests/*.test.tsx Comprehensive test suite for preview components
projects/js-packages/social-previews/src/** Complete source code with platform-specific implementations
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jp-launch-control
Copy link

jp-launch-control bot commented Dec 16, 2025

Code Coverage Summary

107 files are newly checked for coverage. Only the first 5 are listed here.

File Coverage
projects/js-packages/social-previews/src/instagram-preview/post-preview.tsx 0/3 (0.00%) 💔
projects/js-packages/social-previews/src/linkedin-preview/link-preview.tsx 0/1 (0.00%) 💔
projects/js-packages/social-previews/src/linkedin-preview/post-preview.tsx 0/3 (0.00%) 💔
projects/js-packages/social-previews/src/mastodon-preview/post/icons/index.tsx 0/1 (0.00%) 💔
projects/js-packages/social-previews/src/nextdoor-preview/footer-actions.tsx 0/1 (0.00%) 💔

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@manzoorwanijk manzoorwanijk added the I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. label Dec 16, 2025
@manzoorwanijk manzoorwanijk force-pushed the add/social-previews-package-with-history branch from 3fabd29 to 17360ae Compare December 16, 2025 08:51
@manzoorwanijk
Copy link
Member Author

manzoorwanijk commented Dec 16, 2025

OK, I have extracted all the changes I made here into a separate PR (#46315) to make it easier to review. Let us merge that PR into this one as a single commit and then merge this one without squashing the commits.

@kraftbj kraftbj added the DO NOT MERGE don't merge it! label Dec 16, 2025
@kraftbj
Copy link
Contributor

kraftbj commented Dec 16, 2025

Marking as "DO NOT MERGE" just to help everyone remember we can't merge it until disabling the requirement for squash merges.

@anomiex
Copy link
Contributor

anomiex commented Dec 16, 2025

History looks to be imported correctly. 👍

* Update package metadata in package.json

* Update git config

* Use tsup for bundling

* Use stable as current version and update changelogs

* Update consumer workspaces to use the workspace version

* pnpm reformat-files

* Format style files

* Use module import syntax for SCSS

* Create composer.json

* Update README.md

* Fix lints

* Fix tests

* Migrate tests to TS

* Improve and re-use baseDomain

* Use tsconfig.base.json

* Update changelog to fix version headings

* Fix CodeQL warnings

* Fix lints

* Fix doc block comments

* Apply suggestions from @anomiex

Co-authored-by: Brad Jorsch <[email protected]>

* Move react and react-dom to dev and peer dependencies

* Apply suggestions from @anomiex

* Update README to remove unnecessary prerequisites

---------

Co-authored-by: Brad Jorsch <[email protected]>
Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

LGTM. Reminder that this should be done as a merge commit, not the normal squash.

@manzoorwanijk manzoorwanijk marked this pull request as ready for review December 18, 2025 04:19
@manzoorwanijk manzoorwanijk merged commit 38a87e4 into trunk Dec 18, 2025
144 of 146 checks passed
@manzoorwanijk manzoorwanijk deleted the add/social-previews-package-with-history branch December 18, 2025 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DO NOT MERGE don't merge it! Docs [Feature] Publicize Now Jetpack Social, auto-sharing I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [JS Package] Publicize Components [JS Package] Social Previews [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Tests] Includes Tests [Type] Task

Projects

None yet

Development

Successfully merging this pull request may close these issues.