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

JS Package: Add Critical CSS Gen #38429

Merged
merged 90 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
a0c01cb
Add initial files
dilirity Jul 19, 2024
e59f8c6
Fix types
dilirity Jul 19, 2024
8cd8c5f
Add builds for browser and node
dilirity Jul 19, 2024
2d05ea6
Only build for node (for now)
dilirity Jul 19, 2024
443c5ed
Update package.json type to module
dilirity Jul 19, 2024
e9e9e45
Unfix types (these are the original source files)
dilirity Jul 19, 2024
5449deb
Add rollup for browser version (not working properly)
dilirity Jul 19, 2024
b98497c
WIP
dilirity Jul 19, 2024
49a6e99
Ping all package versions
dilirity Jul 19, 2024
8227072
Fix build for browser
dilirity Jul 19, 2024
82bca11
add changelogs
dilirity Jul 19, 2024
601c238
Remove postinstall scripts related to yalc
dilirity Jul 23, 2024
3f237b6
Add missing dependency
dilirity Jul 23, 2024
dac9a56
Don't specify moduleResolution in tsconfig
dilirity Jul 23, 2024
0175acb
Don't set module directly. Jetpack tooling already sets that
dilirity Jul 23, 2024
c095ce7
Add build for browser version
dilirity Jul 23, 2024
a98d4f6
Fix JSDoc blocks
dilirity Jul 23, 2024
849eabb
Remove lock file
dilirity Jul 23, 2024
e36584b
Remove test package
dilirity Jul 23, 2024
bf8a3c3
Update root pnpm-lock
dilirity Jul 23, 2024
386cf11
Merge branch 'trunk' into add/js-package/critical-css-gen
dilirity Jul 23, 2024
26aac64
No useless constructor
dilirity Jul 23, 2024
3e972c7
Fix root lock file out of date
dilirity Jul 23, 2024
8008bd1
Fix pointing to unminified file for css gen package
dilirity Jul 23, 2024
1389dcf
Add back-end/node build
dilirity Jul 23, 2024
b6840dc
Fix map files
dilirity Jul 24, 2024
f132ca3
Fix package entrypoints
dilirity Jul 24, 2024
57dc718
Remove unused dependencies
dilirity Jul 24, 2024
bce7ee2
Add tests
dilirity Jul 24, 2024
1bd7edf
Package resolution
dilirity Jul 24, 2024
cb12bfb
Fix lint issues
dilirity Jul 24, 2024
9e54186
Try to fix tests
dilirity Jul 24, 2024
b912579
Remove global setup
dilirity Jul 24, 2024
dd1e0b6
Add test env for jest
dilirity Jul 24, 2024
f0ed2b8
Install chrome before running project tests
dilirity Jul 24, 2024
daa307d
Setup puppeteer envs
dilirity Jul 24, 2024
7cda928
Fix tests
dilirity Jul 25, 2024
0973553
Update imports
dilirity Jul 25, 2024
07b32e7
Fix incorrectly ignoring directories
dilirity Jul 25, 2024
3f190ff
Remove build from npm test command
dilirity Jul 25, 2024
8dbfea3
I guess building is necessary...
dilirity Jul 25, 2024
b6d3681
Cleanup package dependencies
dilirity Jul 25, 2024
3a926f8
Cleanup babel dependencies
dilirity Jul 25, 2024
72b3d30
Cleanup root lock file
dilirity Jul 25, 2024
435366d
More dependency cleanup
dilirity Jul 25, 2024
dec3a49
Remove unused babel footprint
dilirity Jul 25, 2024
325332c
Fix to remove duplicate puppeteer related dependencies
dilirity Jul 25, 2024
9aa1066
Remove unused dependency
dilirity Jul 25, 2024
46d507b
Merge branch 'trunk' into add/js-package/critical-css-gen
dilirity Jul 25, 2024
86e4d70
Add express back
dilirity Jul 25, 2024
2acdd73
Fix incorrect package usage
dilirity Jul 25, 2024
6628554
Fix jetpack entry file
dilirity Jul 25, 2024
520e67b
Remove unnecessary tsconfig
dilirity Jul 26, 2024
1fcfde5
Remove unused dependencies
dilirity Jul 26, 2024
a5732b3
Update rollup to use the same version as everything else in the monorepo
dilirity Jul 26, 2024
ff625d1
Update package vesion
dilirity Jul 26, 2024
1614926
Update package to match monorepo
dilirity Jul 26, 2024
9905437
Update package to match monorepo
dilirity Jul 26, 2024
50bed1f
Update package version
dilirity Jul 26, 2024
4e91c57
Update package version
dilirity Jul 26, 2024
a0e29e7
Cleanup eslint dependencies, since they are handled at monorepo level
dilirity Jul 26, 2024
6ecc66a
Dedupe packages
dilirity Jul 26, 2024
84e9a26
Update build to use pnpm instead of npm
dilirity Jul 26, 2024
bb22c70
Update test script to use pnpm instead of npm
dilirity Jul 26, 2024
b2af06a
Use playwright instead of puppeteer
dilirity Jul 26, 2024
f2820eb
Fix browser-interface-iframe tests
dilirity Jul 26, 2024
324318c
Fix generate-critical-css not working with local files
dilirity Jul 26, 2024
f4bd162
Add build before tests
dilirity Jul 26, 2024
03cc8d1
Remove chrome setup as puppeteer is no longer present
dilirity Jul 26, 2024
501a5ff
Build before running tests
dilirity Jul 26, 2024
a7f447d
Fix incorrectly parsing file paths
dilirity Jul 26, 2024
9dce36d
Remove unused dependencies
dilirity Jul 26, 2024
e55a53a
Remove peer dependencies meta property
dilirity Jul 26, 2024
9ac3a1b
Update dependencies versions
dilirity Jul 26, 2024
c1d30be
Replace node-fetch in favor of node 18.0.0s fetch
dilirity Jul 26, 2024
1615665
Install browsers before running tests
dilirity Jul 26, 2024
03ad381
Update gitattributes
dilirity Jul 29, 2024
330e5d8
Rename build folders to make sense at a glance
dilirity Jul 29, 2024
3f586d8
Revert update to boost to use new package
dilirity Jul 29, 2024
5c69332
Add a separate entry point for playwright interface
dilirity Jul 29, 2024
f1bfe32
Update node/browser entry files names
dilirity Jul 29, 2024
ceac716
Fix using incorrect entry file for browser build
dilirity Jul 29, 2024
15b34b5
Remove unused globals from browser build
dilirity Jul 29, 2024
4d0dd5d
Exclude browser config from production build
dilirity Jul 29, 2024
b6d6987
Make playwright-core a required peer dependency
dilirity Jul 29, 2024
79678eb
Make playwright-core a production dependency
dilirity Jul 29, 2024
9104f99
Remove separate entry point for playwright
dilirity Jul 29, 2024
86aae3a
Make playwright a dev depepdency
dilirity Jul 30, 2024
54c9158
Merge branch 'trunk' into add/js-package/critical-css-gen
dilirity Jul 31, 2024
8ca2f79
Make playwright-core an optional peer dependency
dilirity Jul 31, 2024
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
611 changes: 397 additions & 214 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions projects/js-packages/critical-css-gen/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Files not needed to be distributed in the package.
.gitattributes export-ignore
node_modules export-ignore

# Files to include in the mirror repo
/build-browser/** production-include
/build-node/** production-include

# Files to exclude from the mirror repo
/changelog/** production-exclude
/src/** production-exclude
/tests/** production-exclude
/rollup.config.js production-exclude
/jest.config.cjs production-exclude
/tsconfig.browser.json production-exclude
4 changes: 4 additions & 0 deletions projects/js-packages/critical-css-gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/vendor
/node_modules
/build-node
/build-browser
7 changes: 7 additions & 0 deletions projects/js-packages/critical-css-gen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

24 changes: 24 additions & 0 deletions projects/js-packages/critical-css-gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# critical-css-gen

A flexible Critical CSS Generator that supports multiple URLs and viewports, with both server-side and client-side generation capabilities.

## How to install critical-css-gen

### Installation From Git Repo

## Contribute

## Get Help

## Using this package in your WordPress plugin

If you plan on using this package in your WordPress plugin, we would recommend that you use [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.

## Security

Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic).

## License

critical-css-gen is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add package files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Initial version.
44 changes: 44 additions & 0 deletions projects/js-packages/critical-css-gen/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "automattic/jetpack-critical-css-gen",
"description": "A flexible Critical CSS Generator that supports multiple URLs and viewports, with both server-side and client-side generation capabilities.",
"type": "library",
"license": "GPL-2.0-or-later",
"require": {},
"require-dev": {
"automattic/jetpack-changelogger": "@dev"
},
"autoload": {
"classmap": [
"src/"
]
},
"scripts": {
"build-development": [
"pnpm run build"
],
"build-production": [
"NODE_ENV=production pnpm run build"
],
"test-js": [
"pnpm exec playwright install && pnpm run test"
]
},
"repositories": [
{
"type": "path",
"url": "../../packages/*",
"options": {
"monorepo": true
}
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"autotagger": true,
"changelogger": {
"link-template": "https://github.com/Automattic/jetpack-critical-css-gen/compare/v${old}...v${new}"
},
"mirror-repo": "Automattic/jetpack-critical-css-gen"
}
}
5 changes: 5 additions & 0 deletions projects/js-packages/critical-css-gen/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseConfig = require( 'jetpack-js-tools/jest/config.base.js' );

module.exports = {
...baseConfig,
};
78 changes: 78 additions & 0 deletions projects/js-packages/critical-css-gen/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"private": true,
"type": "module",
"name": "@automattic/jetpack-critical-css-gen",
"version": "0.1.0-alpha",
"description": "A flexible Critical CSS Generator that supports multiple URLs and viewports, with both server-side and client-side generation capabilities.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/critical-css-gen/#readme",
"bugs": {
"url": "https://github.com/Automattic/jetpack/labels/[JS Package] Critical Css Gen"
},
"repository": {
"type": "git",
"url": "https://github.com/Automattic/jetpack.git",
"directory": "projects/js-packages/critical-css-gen"
},
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"build:browser": "rollup -c",
"build:node": "tsc",
"build": "pnpm run clean && pnpm run build:browser && pnpm run build:node",
"clean": "rm -rf build-node/ && rm -rf build-browser/",
"test": "pnpm build && NODE_ENV=test NODE_PATH=./node_modules jest --forceExit --config=tests/config/jest.config.js"
},
"main": "./build-node/node.js",
"browser": "./build-browser/bundle.js",
"devDependencies": {
"@babel/core": "7.24.7",
"@babel/preset-env": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.3.0",
"@rollup/plugin-terser": "0.4.3",
"@rollup/plugin-typescript": "8.3.3",
"@types/clean-css": "4.2.5",
"@types/css-tree": "2.0.1",
"@types/node": "^20.4.2",
"express": "4.19.2",
"jest": "29.7.0",
"playwright": "1.45.1",
"playwright-core": "^1.45.1",
"prettier": "npm:[email protected]",
"rollup": "2.79.1",
"rollup-plugin-polyfill-node": "0.13.0",
"source-map": "0.7.4",
"source-map-js": "1.2.0",
"tslib": "2.5.0",
"typescript": "5.0.4",
"webpack": "5.76.0",
"webpack-dev-middleware": "5.3.4"
},
"exports": {
".": {
"jetpack:src": "./src/node.ts",
"types": "./build-node/node.d.ts",
"browser": "./build-browser/bundle.js",
"import": "./build-node/node.js",
"require": "./build-node/node.js",
"default": "./build-node/node.js"
}
},
"dependencies": {
"clean-css": "^5.3.1",
"css-tree": "^2.3.1"
},
"peerDependencies": {
"playwright-core": "^1.45.1"
},
"peerDependenciesMeta": {
"playwright-core": {
"optional": true
}
},
"engines": {
"node": ">=18.0.0"
}
}
47 changes: 47 additions & 0 deletions projects/js-packages/critical-css-gen/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import nodePolyfills from 'rollup-plugin-polyfill-node';

const sharedPlugins = [
resolve( {
browser: true,
preferBuiltins: false,
modulesOnly: false,
} ),
typescript( {
tsconfig: 'tsconfig.browser.json',
sourceMap: true,
inlineSources: false,
declaration: false,
} ),
commonjs(),
nodePolyfills(),
json(),
];

export default {
input: 'src/browser.ts',
output: [
{
sourcemap: true,
format: 'iife',
name: 'CriticalCSSGenerator',
file: 'build-browser/bundle.full.js',
},
{
sourcemap: true,
format: 'iife',
name: 'CriticalCSSGenerator',
file: 'build-browser/bundle.js',
plugins: [ terser() ],
},
],
plugins: sharedPlugins,
preserveSymlinks: true,
watch: {
clearScreen: false,
},
};
Loading
Loading