-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Private APIs] Only prevent module re-registration if IS_WORDPRESS_CORE #48352
[Private APIs] Only prevent module re-registration if IS_WORDPRESS_CORE #48352
Conversation
…opt-out Gutenberg introduced a system of sharing private APIs in #46131. One of the safeguards is a check preventing the same module from opting-in twice so that contributors cannot easily gain access by pretending to be a core module. That safeguard is only meant for WordPress core and not for the released @WordPress packages. However, right now it is opt-out and must be explicitly disabled by developers wanting to install the @WordPress packages. Let's make it opt-out instead. This commit makes the check opt-in rather than opt-out. Its counterpart in the wordpress-develop repo makes WordPress explicitly set the ALLOW_EXPERIMENT_REREGISTRATION to false: WordPress/wordpress-develop#4121
Size Change: +559 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7e9d944. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4251868954
|
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.
I'm not the best suited to review it as I miss full context, but it seem to resolve the issue. It makes the flag optional only where necessary which is always good.
Unrelated to this PR, I saw recently that process.env
is no longer integrated with webpack 5 so maybe it isn't the most future proof method but it will work for WordPress Core that we care about.
Totally optional as I had this afterthought after clicking |
I tried to come up with a better name, but couldn't. This API is now for private APIs, not experiments, so it would have to be |
Maybe we need |
Ooh i like it @gziolo, let's go for that one |
I'm curious if one day we could simplify it to |
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.
Still good to go and I like the magic global more now.
Further ideas are better suited for a different PR as it might have implications on TS and ESLint configuration.
Description
Gutenberg introduced a system of sharing private APIs in #46131. One of the safeguards is a check preventing the same module from opting-in twice so that contributors cannot easily gain access by pretending to be a core module.
That safeguard is only meant for WordPress core and not for the released @WordPress packages. However, right now it is opt-out and must be explicitly disabled by developers wanting to install the @WordPress packages. Let's make it opt-out instead.
In other words:
Or:
The corresponding PR in
wordpress-develop
repo makes WordPress explicitly set theIS_WORDPRESS_CORE
to true:WordPress/wordpress-develop#4121
Test plan
packages/data/src/js/private-apis.js
to the code snippet below