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

Add a "wordpress-dataviews-snapshot" package #40612

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/files/lint-project-structure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ for PROJECT in projects/*/*; do

# - Only plugins can use non-semver versioning.
# - Changelog header should not mention semver if project does not use semver.
if jq -e '( .extra.changelogger.versioning // "semver" ) != "semver"' "$PROJECT/composer.json" >/dev/null; then
if jq -e '.extra.changelogger.versioning // "semver" | type == "string" and . != "semver"' "$PROJECT/composer.json" >/dev/null; then
if [[ "$TYPE" != "plugins" ]]; then
EXIT=1
LINE=$(jq --stream -r 'if length == 1 then .[0][:-1] else .[0] end | if . == ["extra","changelogger","versioning"] then ",line=\( input_line_number )" else empty end' "$PROJECT/composer.json")
Expand Down
28 changes: 28 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@ function fixDeps( pkg ) {
pkg.dependencies.undici = '*';
}

// Missing deps.
// https://github.com/WordPress/gutenberg/issues/67864
if ( pkg.name === '@wordpress/dataviews' && pkg.version === '4.10.0' ) {
for ( const dep of [
'change-case',
'colord',
'date-fns',
'deepmerge',
'@emotion/cache',
'@emotion/css',
'@emotion/react',
'@emotion/styled',
'@emotion/utils',
'fast-deep-equal',
'@floating-ui/react-dom',
'framer-motion',
'highlight-words-core',
'is-plain-object',
'memize',
'react-dom',
'@use-gesture/react',
'use-memo-one',
'uuid',
] ) {
pkg.optionalDependencies[ dep ] = '*';
}
}

// Turn @wordpress/eslint-plugin's eslint plugin deps into peer deps.
// https://github.com/WordPress/gutenberg/issues/39810
if ( pkg.name === '@wordpress/eslint-plugin' ) {
Expand Down
92 changes: 79 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

BREAKING: Use of `@wordpress/dataviews` will now throw an error, with instructions on how to use the new `automattic/jetpack-wordpress-dataviews-snapshot` composer package.
14 changes: 14 additions & 0 deletions projects/js-packages/webpack-config/src/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,30 @@ const defaultRequestMap = {
external: 'JetpackConnection',
handle: 'jetpack-connection',
},
'@wordpress/dataviews': {
fail: `@wordpress/dataviews is not stable! Please use the automattic/jetpack-wordpress-dataviews-snapshot composer package to get a snapshot version.\nSee projects/packages/wordpress-dataviews-snapshot/README.jetpack-monorepo.md for instructions.`,
},
'@wordpress/dataviews/wp': {
fail: `Using @wordpress/dataviews/wp will bloat your bundle. The automattic/jetpack-wordpress-dataviews-snapshot composer package provides an extracted version.\nSee projects/packages/wordpress-dataviews-snapshot/README.jetpack-monorepo.md for instructions.`,
},
};

const DependencyExtractionPlugin = ( { requestMap, ...options } = {} ) => {
const finalRequestMap = { ...defaultRequestMap, ...requestMap };

const maybeFail = request => {
if ( finalRequestMap[ request ]?.fail ) {
throw new Error( finalRequestMap[ request ].fail );
}
};

const requestToExternal = request => {
maybeFail( request );
return finalRequestMap[ request ]?.external;
};

const requestToHandle = request => {
maybeFail( request );
return finalRequestMap[ request ]?.handle;
};

Expand Down
19 changes: 19 additions & 0 deletions projects/packages/wordpress-dataviews-snapshot/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Files not needed to be distributed in the package.
.gitattributes export-ignore
.github/ export-ignore

# Files to include in the mirror repo, but excluded via gitignore
# Remember to end all directories with `/**` to properly tag every file.
build/** production-include

# Files to exclude from the mirror repo, but included in the monorepo.
# Remember to end all directories with `/**` to properly tag every file.
.gitignore production-exclude
changelog/** production-exclude
.phpcs.dir.xml production-exclude
src/**/*.js production-exclude
tools/** production-exclude
.phpcsignore production-exclude
package.json production-exclude
webpack.config.cjs production-exclude
README.jetpack-monorepo.md production-exclude
4 changes: 4 additions & 0 deletions projects/packages/wordpress-dataviews-snapshot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
node_modules/
build/
.cache/
13 changes: 13 additions & 0 deletions projects/packages/wordpress-dataviews-snapshot/.phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* This configuration will be read and overlaid on top of the
* default configuration. Command-line arguments will be applied
* after this file is read.
*
* @package automattic/jetpack-wordpress-dataviews-snapshot
*/

// Require base config.
require __DIR__ . '/../../../../.phan/config.base.php';

return make_phan_config( dirname( __DIR__ ) );
24 changes: 24 additions & 0 deletions projects/packages/wordpress-dataviews-snapshot/.phpcs.dir.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruleset>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="jetpack-wordpress-dataviews-snapshot" />
</property>
</properties>
</rule>
<rule ref="Jetpack.Functions.I18n">
<properties>
<property name="text_domain" value="jetpack-wordpress-dataviews-snapshot" />
</properties>
</rule>

<rule ref="WordPress.Utils.I18nTextDomainFixer">
<properties>
<property name="old_text_domain" type="array" />
<property name="new_text_domain" value="jetpack-wordpress-dataviews-snapshot" />
</properties>
</rule>

</ruleset>
7 changes: 7 additions & 0 deletions projects/packages/wordpress-dataviews-snapshot/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).

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Usage in the Jetpack Monorepo

1. Add `automattic/jetpack-wordpress-dataviews-snapshot` to "requires" in your composer.json.
2. Arrange for the `init.php` file to be required sometime before `wp_loaded` priority 10, something like this.
```php
require_once __DIR__ . '/jetpack_vendor/automattic/jetpack-wordpress-dataviews-snapshot/init.php';
```
This is necessary to register the script handle.
3. In your Webpack configs, find any invocations of the `StandardPlugins()` function and pass it an options object like this.
```js
{
DependencyExtractionPlugin: {
requestMap: {
'@wordpress/dataviews': require(
path.join(
__dirname,
'jetpack_vendor/automattic/jetpack-wordpress-dataviews-snapshot/build/dependency-data.json'
)
),
},
},
}
```
If you're already passing an options object, merge this into it.
18 changes: 18 additions & 0 deletions projects/packages/wordpress-dataviews-snapshot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# jetpack-wordpress-dataviews-snapshot

Provide `@wordpress/dataviews` as an extracted module.

Note this package is intended to be temporary. Once `@wordpress/dataviews` is declared stable upstream and is shipped in a few versions of WordPress Core, this will be retired.

## Usage

TODO: Write this.

## 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

jetpack-wordpress-dataviews-snapshot 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: patch
Type: added

Initial version.
Loading
Loading