Skip to content

Conversation

@sidharthpandita1
Copy link
Contributor

@sidharthpandita1 sidharthpandita1 commented Oct 4, 2025

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.

@github-actions
Copy link

github-actions bot commented Oct 4, 2025

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.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin, New Block.
  • Labels found: .

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.

@github-actions
Copy link

github-actions bot commented Oct 4, 2025

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.

Unlinked Accounts

The 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.

Unlinked contributors: sidharthpandita1, EmranAhmed.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@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 added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 4, 2025
@github-actions
Copy link

github-actions bot commented Oct 4, 2025

👋 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 t-hamano added [Type] Enhancement A suggestion for improvement. [Tool] Create Block /packages/create-block labels Oct 4, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Mamaduka
Copy link
Member

Mamaduka commented Oct 6, 2025

Is this PR for #72057?

@t-hamano
Copy link
Contributor

t-hamano commented Oct 6, 2025

Is this PR for #72057?

That's correct 👍

@t-hamano t-hamano changed the title created block support alias Create Block: Enable alias package installation Oct 6, 2025
@t-hamano t-hamano merged commit d560cbf into WordPress:trunk Oct 7, 2025
76 of 77 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.9 milestone Oct 7, 2025
sidharthpandita1 added a commit to sidharthpandita1/gutenberg that referenced this pull request Oct 10, 2025
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Tool] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable alias package installation in custom templates with @wordpress/create-block

3 participants