Skip to content

Private APIs: Deprecate the '@wordpress/dataviews' opt-in, scheduling removal for WordPress 7.4 - #82231

Open
oandregal wants to merge 3 commits into
trunkfrom
add/private-apis-deprecated-modules
Open

oandregal wants to merge 3 commits into
trunkfrom
add/private-apis-deprecated-modules

Conversation

@oandregal

Copy link
Copy Markdown
Member

What?

Follow up to #82221 (see this discussion). Moves @wordpress/dataviews from the list of core modules allowed to use private APIs to a new list of deprecated modules. Opting in as a deprecated module still works, but logs a deprecation warning, and its removal is scheduled for WordPress 7.4.

Why?

@wordpress/dataviews copies published to npm before v18 call the private APIs opt-in when they load, so a plugin bundling one of them would break the moment we remove the entry. We still want to remove it eventually, and developers need a heads-up on how to prepare (update the npm dependency to v18 or newer).

How?

Adds a DEPRECATED_CORE_MODULES list to @wordpress/private-apis. Modules on it still get lock/unlock, but a warning is logged once per module when SCRIPT_DEBUG is enabled, naming the removal version and the fix. A new unit test starts failing as soon as a lib/compat/wordpress-7.4 directory appears, so the removal cannot be forgotten; actual usage of old copies in the plugin directory should still be checked before removing.

Testing Instructions

Run npm run test:unit -- packages/private-apis. To see the warning in a browser, open the editor in a dev environment with SCRIPT_DEBUG enabled and run wp.privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules( 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/dataviews' ) in the console: it returns the lock/unlock utilities and logs the deprecation warning once.

Use of AI Tools

This PR was written with the help of Claude Code, based on the discussion linked above. The changes were reviewed, tested, and are owned by the author.

… removal for WordPress 7.4

Move '@wordpress/dataviews' from the allowed core modules to a new
DEPRECATED_CORE_MODULES list. Opting in as a deprecated module still
works, so previously published npm copies keep loading, but it logs a
deprecation warning when SCRIPT_DEBUG is enabled. A unit test starts
failing when the WordPress 7.4 release cycle begins, prompting the
actual removal.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LjZ4WCUJRKsVT8Uds1gKgp
@github-actions github-actions Bot added the [Package] Private APIs /packages/private-apis label Aug 31, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LjZ4WCUJRKsVT8Uds1gKgp
@oandregal oandregal added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 31, 2026
@oandregal
oandregal marked this pull request as ready for review August 31, 2026 06:41
Copilot AI balanced review requested due to automatic review settings August 31, 2026 06:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Size Change: +98 B (0%)

Total Size: 7.92 MB

📦 View Changed
Filename Size Change
build/scripts/private-apis/index.min.js 1.25 kB +98 B (+8.51%) 🔍

compressed-size-action

@oandregal
oandregal requested a review from tyxla August 31, 2026 06:47
Comment thread packages/private-apis/CHANGELOG.md Outdated
Comment thread packages/private-apis/src/implementation.ts Outdated
18.1 is the DataViews version that no longer uses private APIs

Co-authored-by: André <583546+oandregal@users.noreply.github.com>
Comment on lines +355 to +387
it( 'Should be removed when the WordPress version scheduled for their removal is reached', () => {
// The newest lib/compat/wordpress-X.Y directory marks the WordPress
// release Gutenberg is currently targeting.
const compatDir = path.join( __dirname, '../../../../lib/compat' );
const targetedVersion = fs
.readdirSync( compatDir )
.map( ( name ) => name.match( /^wordpress-(\d+)\.(\d+)$/ ) )
.filter( Boolean )
.map( ( match ) => [ Number( match[ 1 ] ), Number( match[ 2 ] ) ] )
.sort( ( a, b ) => a[ 0 ] - b[ 0 ] || a[ 1 ] - b[ 1 ] )
.pop();

const dueForRemoval = [];
for ( const [ moduleName, { removal } ] of Object.entries(
DEPRECATED_CORE_MODULES
) ) {
const [ major, minor ] = removal.split( '.' ).map( Number );
const isReached =
targetedVersion[ 0 ] > major ||
( targetedVersion[ 0 ] === major &&
targetedVersion[ 1 ] >= minor );
if ( isReached ) {
dueForRemoval.push(
`The "${ moduleName }" entry in DEPRECATED_CORE_MODULES was scheduled ` +
`for removal in WordPress ${ removal }, and the ` +
`${ targetedVersion[ 0 ] }.${ targetedVersion[ 1 ] } release cycle has started. ` +
`Remove the entry and its deprecation warning, unless old copies of the ` +
`module are still in significant use by plugins.`
);
}
}
expect( dueForRemoval ).toEqual( [] );
} );

@oandregal oandregal Aug 31, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Given the long timelines to make this change, I though having something that acts as an alarm would be of help. Having a failing test is a better signal than relying on people's memory.

However, I don't like that this test starts failing when we create the lib/compat/wordpress-X.Y/ folder, as that requires the PR that creates the folder to also remove the deprecated entry.

Happy to hear alternatives.

@aduth aduth Aug 31, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Happy to hear alternatives.

I implemented an alternative way back in #5491 for exactly this reason but I see that we gave up on this in #68590 (in part due to changes in how we track WordPress version and not Gutenberg). For what it's worth, I felt and feel quite strongly that we should be consistent about this and enforce it project-wide.

Comment on lines +100 to +104
// eslint-disable-next-line no-console
console.warn(
`The private APIs opt-in of the module "${ moduleName }" is deprecated since WordPress ${ since } ` +
`and will stop working in WordPress ${ removal }. ${ note }`
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use @wordpress/deprecated for this?

And if we do, can we update the typings of DEPRECATED_CORE_MODULES value to reuse the existing type signature from @wordpress/deprecated accordingly?

Comment on lines +11 to +12
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable @wordpress/wp-global-usage */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd suggest just adding the pairing at the bottom of the file than to disable the disable-enable rule, which exists largely for this pattern. Ideally we could scope the disabling rule more precisely to where we expect it to exist.

Given that we also disable this in the implementation, I'd wonder if it's something where the package or file pattern should be exempt from the rule. Though to be honest, I don't really understand the purpose of the @wordpress/wp-global-usage rule to begin with.

warnedDeprecatedModules.clear();
}

export { DEPRECATED_CORE_MODULES };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we export this at the variable assignment? Not sure if we have this as a normal convention elsewhere.

@aduth aduth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Meant to approve with those comments, nothing blocking here 👍

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Private APIs /packages/private-apis [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants