-
Notifications
You must be signed in to change notification settings - Fork 800
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
JS Package: Add Critical CSS Gen #38429
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Boost plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
@@ -0,0 +1,125 @@ | |||
import { BrowserContext, Page } from 'playwright-core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's not as bad as I thought since it's only importing types. Still, try this:
- Fix the
.gitattributes
as mentioned in the other comment. - Download the build artifact from this PR, and unpack it to something like
/tmp/jetpack-build
.- Or, from a fresh checkout, do
pnpm install && jetpack build --for-mirrors=/tmp/jetpack-build js-packages/critical-css-gen
.
- Or, from a fresh checkout, do
- Create package.json with these contents:
{ "dependencies": { "@automattic/jetpack-critical-css-gen": "file:/tmp/jetpack-build/Automattic/jetpack-critical-css-gen", "typescript": "^5.5.4" } }
- Create index.ts with these contents:
import { generateCriticalCSS } from '@automattic/jetpack-critical-css-gen'; console.log( 'The function is:', generateCriticalCSS );
- Run
npm install && npm exec tsc index.ts
.
You'll get an error like
../jetpack-build/Automattic/jetpack-critical-css-gen/lib/browser-interface-playwright.d.ts:1:38 - error TS2307: Cannot find module 'playwright-core' or its corresponding type declarations.
1 import { BrowserContext, Page } from 'playwright-core';
~~~~~~~~~~~~~~~~~
Found 1 error in ../jetpack-build/Automattic/jetpack-critical-css-gen/lib/browser-interface-playwright.d.ts:1
Unfortunately, it looks like using an optional (peer) dependency to account for this case is complicated.
- Seems like the most straightforward way would be to have a separate entry point for
BrowserInterfacePlaywright
so people can do likeimport { BrowserInterfacePlaywright } from '@automattic/jetpack-critical-css-gen/playwright';
if they need it, rather than including it in the default entry point. - Second way would be to get tsc to include a
// @ts-ignore
comment before theimport
line when it outputslib/browser-interface-playwright.d.ts
. By default it seems to strip those, not sure how to best configure it not to.
Co-authored-by: Brad Jorsch <[email protected]>
We should release the package first then update Boost. That way we can be sure that doing a new Boost release will not ship broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing and I think it's ready to get merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fixes https://github.com/Automattic/boost-cloud/issues/267
Proposed changes:
build-browser
(wasdist
before);build-node
(waslib
before);Update Boost to use the new package instead of the external repo.This will be done in a follow-up PR.Other information:
Jetpack product discussion
n/a
Does this pull request change what data or activity we track or use?
no
Testing instructions:
Pre-requisites
pnpm install
;pnpm build
;Testing with the Boost plugin
jetpack install plugins/boost
;jetpack build plugins/boost
;