-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Create Block: Enable alias package installation
#72079
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
Create Block: Enable alias package installation
#72079
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @sidharthpandita1, @EmranAhmed. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @sidharthpandita1! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
t-hamano
left a comment
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.
LGTM 👍
|
Is this PR for #72057? |
That's correct 👍 |
alias package installation
* created block support alias * updated changelog * CHANGED CHANGELOG.MD ACCORDINGLY * Fix ESLint error * Fix ESLint error * Update packages/create-block/CHANGELOG.md --------- Unlinked contributors: sidharthpandita1, EmranAhmed. Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
old pr--> #72074
What?
Closes
Add support for npm alias package type in the @wordpress/create-block template dependency checker.
Specifically, this PR updates the checkDependency logic so the alias type is accepted when parsing dependency strings (e.g. prettier@npm:wp-prettier@2.8.5).
Changed file:
packages/create-block/lib/init-package-json.js
Why?
Currently, @wordpress/create-block rejects aliased dependencies declared in custom templates with the error:
Provided package type "alias" is not supported.
This prevents template authors from using npm package aliases (for example, pointing to a fork or a workspace package under a different name). Allowing alias improves flexibility for template authors and makes it easier to reference alternative package sources (e.g. prettier@npm:wp-prettier@latest) without renaming or forking packages in templates.
How?
The PR updates the checkDependency function to include alias among the supported npm package argument types returned by npmPackageArg(...).
Example change:
function checkDependency(packageArg) {
const { type } = npmPackageArg(packageArg);
if (
!['git', 'tag', 'version', 'range', 'remote', 'alias'].includes(type) // added 'alias'
) {
throw new Error(
Provided package type "${type}" is not supported.
);
}
}
No other behavior is changed. The change is intentionally minimal — it only permits the alias type to pass the existing validation so downstream installation/resolve flows can proceed as normal.