Skip to content
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

[Bug] - Packages npm request @wordpress/upload-media #68490

Closed
3 of 6 tasks
xxxxvu opened this issue Jan 5, 2025 · 9 comments
Closed
3 of 6 tasks

[Bug] - Packages npm request @wordpress/upload-media #68490

xxxxvu opened this issue Jan 5, 2025 · 9 comments
Assignees
Labels
[Feature] Media Anything that impacts the experience of managing media Needs Technical Feedback Needs testing from a developer perspective. [Status] In Progress Tracking issues with work in progress [Status] Needs More Info Follow-up required in order to be actionable. [Type] Bug An existing feature does not function as intended

Comments

@xxxxvu
Copy link

xxxxvu commented Jan 5, 2025

Description

Packages npm request @wordpress/upload-medianpm packages request @wordpress/upload-media. The block editor packages require media upload, but when running npm install @wordpress/upload-media or yarn add @wordpress/upload-media, it reports that the package does not exist.

Step-by-step reproduction instructions

yarn add @wordpress/upload-media

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@xxxxvu xxxxvu added the [Type] Bug An existing feature does not function as intended label Jan 5, 2025
@Mamaduka Mamaduka added [Feature] Media Anything that impacts the experience of managing media Needs Technical Feedback Needs testing from a developer perspective. labels Jan 5, 2025
@Mamaduka
Copy link
Member

Mamaduka commented Jan 5, 2025

@xxxxvu, @wordpress/upload-media is a private package (see #66290).

Are you trying to install it directly, or do you get errors when installing a different package?

@Mamaduka Mamaduka added the [Status] Needs More Info Follow-up required in order to be actionable. label Jan 5, 2025
@xxxxvu
Copy link
Author

xxxxvu commented Jan 5, 2025

@xxxxvu, @wordpress/upload-media is a private package (see #66290).

Are you trying to install it directly, or do you get errors when installing a different package?

thanks for responding, i installed @wordpress/block-editor and @wordpress/block-library

@Mamaduka
Copy link
Member

Mamaduka commented Jan 5, 2025

@swissspidy, do you have any thoughts? I think those packages should work just fine, but they won't have any enhancements from the private/experimental packages.

@xxxxvu
Copy link
Author

xxxxvu commented Jan 5, 2025

@swissspidy, do you have any thoughts? I think those packages should work just fine, but they won't have any enhancements from the private/experimental packages.

you can view on https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/provider/index.js. It's use upload-media but it's not installed this package

@swissspidy
Copy link
Member

The idea was to not publish the package yet because it‘s still experimental. That‘s why it‘s not listed in the dependencies. So installing should actually work just fine.

Please share more concrete steps to reproduce and I can take a look after my holiday vacation.

@acicovic
Copy link

acicovic commented Jan 6, 2025

It seems that this is the reason some of our tests started failing.

Here's a sample test failure, as well as the originating dependabot PR. Any suggestions?

Thank you.

@swissspidy
Copy link
Member

Hmm it seems like we'd either have to do some dynamic import in packages/block-editor/src/components/provider/index.js to avoid that failing package lookup (maybe with Suspense?), or we have to actually publish this on npm 🤔 I'd prefer the former as this package is still in so early stages.

@jsnajdr
Copy link
Member

jsnajdr commented Jan 7, 2025

If the @wordpress/block-editor package imports @wordpress/upload-media, then the block-editor package published on NPM is broken, because it has an import that it cannot ever satisfy. The upload-media package was not even published.

IMO the best way to solve this is to:

  1. Remove the private: true flag from upload-media, and publish it normally to NPM. Set the version to 0.0.1 to indicate that the package is alpha and unstable. That's common practice on NPM, and the NPM packages are not really bound by any WordPress back-compat constraints.
  2. Prevent creating an unstable wp-upload-media WordPress script by bundling the upload-media package together with wp-block-editor. That can be achieved by adding @wordpress/upload-media to the two BUNDLED_PACKAGES arrays: in the DEWP plugin and in tools/webpack/packages.js.

An alternative is to do some dynamic import like:

try {
  return await import( '@wordpress/upload-media' );
} catch {
  /* ... */
}

but that looks much more complicated than just publishing an alpha version on NPM.

@Mamaduka
Copy link
Member

Mamaduka commented Jan 8, 2025

Fixed via #68522.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Media Anything that impacts the experience of managing media Needs Technical Feedback Needs testing from a developer perspective. [Status] In Progress Tracking issues with work in progress [Status] Needs More Info Follow-up required in order to be actionable. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants