-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Build: Support third-party plugin scripts properly #72760
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
Conversation
|
Size Change: 0 B Total Size: 2.37 MB ℹ️ View Unchanged
|
|
Something I'd love to be able to do with this build tool and custom package namespaces is also doing the dependency extraction. (I want to be able to add my own custom mapping for externalized packages) Woo for example has The key here is that it should be something that can work across multiple packages. I may have one plugin that references packages from another plugin. |
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This is what this PR allows for your own plugin, but I guess we can also add a config for additional plugins like say : |
Yeah this is what I was trying to say but didn't quite find the words for it 😂
This would be perfect 👍 |
|
@fabiankaegy Added :) |
Refs #72032
What?
This PR adds custom namespace support to
@wordpress/build, allowing third-party plugins to expose their own global variables (e.g.,window.myPlugin.*) instead of being restricted to thewp.*. It also allows disabling global generation.Why?
Currently,
@wordpress/buildis hardcoded to use thewpnamespace for all packages. This limits third-party plugins that want to:How?
wpPlugin.scriptGlobalandwpPlugin.packageNamespaceconfiguration to rootpackage.jsonbuild.mjsto conditionally setglobalNamebased on package namespace matchingwordpress-externals-plugin.mjsto use unified configuration for both WordPress and custom namespacesConfiguration example:
{ "wpPlugin": { "scriptGlobal": "myPlugin", "packageNamespace": "my-plugin" } }Behavior:
Testing Instructions