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

Packages are lacking proper dependencies #1630

Closed
swissspidy opened this issue Jul 19, 2024 · 13 comments
Closed

Packages are lacking proper dependencies #1630

swissspidy opened this issue Jul 19, 2024 · 13 comments
Assignees

Comments

@swissspidy
Copy link
Member

I wanted to install @wp-playground/cli via npm but I'm getting an error because it requires version 0.9.20 of @wp-playground/wordpress-builds which for some reason isn't published to npm:

npx --yes @wp-playground/cli start
npm error code ETARGET
npm error notarget No matching version found for @wp-playground/[email protected].

Pinning to 0.9.19 works, but then I'm getting an error because @wp-playground/blueprints is looking for @php-wasm/scopes which is not installed because it is not in the dependencies section of the package.

If they are properly added, then maybe I am able to install these packages via npm

@brandonpayton
Copy link
Member

Hi @swissspidy I haven't had a chance to look into it yet, but it looks like this is due to a GH workflow error:

lerna ERR! E413 Payload Too Large

https://github.com/WordPress/wordpress-playground/actions/runs/9960370683/job/27519444281#step:6:1678

It would be lovely if it was not possible to partially publish new package versions.

@brandonpayton
Copy link
Member

Both packages with large archive sizes, @php-wasm/node and @php-wasm/web, are logged to have published successfully:

I'm going to re-attempt the package publishing job. It will probably bump the version number again, but if this was a momentary error, it will be worth it to fix the latest packages.

@brandonpayton
Copy link
Member

Ah, right. The failed publish was likely @wp-playground/wordpress-builds which also has a larger size. From a previous successful publish run:

lerna notice === Tarball Details === 
lerna notice name:          @wp-playground/wordpress-builds          
lerna notice version:       0.9.19                                   
lerna notice filename:      wp-playground-wordpress-builds-0.9.19.tgz
lerna notice package size:  158.5 MB                                 
lerna notice unpacked size: 363.5 MB                                 
lerna notice shasum:        806b280d2d501431c0aacc5b95f423e32f20c63b 
lerna notice integrity:     sha512-dlqvh/MJDpE5W[...]3YtAtujNC5Mpw== 
lerna notice total files:   11971        

@brandonpayton
Copy link
Member

Rerunning the workflow didn't fail but also didn't appear to publish anything.

@brandonpayton
Copy link
Member

Next things to try:

  • Try running a fresh publish workflow
  • If that fails, perhaps the @wp-playground/wordpress-builds package is indeed too large, and to attempt to alleviate this, we can manually remove WP 6.2 from wordpress-builds because we only support the current version and three prior versions (6.5, 6.4, and 6.3).

brandonpayton added a commit that referenced this issue Jul 19, 2024
## Motivation for the change, related issues

This PR removes support for WP 6.2 which is unsupported following the WP
6.6 release.

The actual motivation for this change is to try to work around the npm
package release error encountered here:

https://github.com/WordPress/wordpress-playground/actions/runs/9960370683/job/27519444281

With this change the `@wp-playground/wordpress-builds` unpacked size
goes from 529M to 485M (based on `du` utility output for a local build).
Lerna reported that the previous, successful release of the package had
a size of 363.5 MB.

Related to #1630

## Testing Instructions (or ideally a Blueprint)

- CI
- Use `npm run dev` to confirm that WP 6.2 is no longer offered as an
option in the UI and that Playground continues to load without error.
@brandonpayton
Copy link
Member

brandonpayton commented Jul 19, 2024

I attempted publishing NPM again without any changes to @wp-playground/wordpress-builds, and publishing failed. So I merged #1632 to remove the WP 6.2 builds and tried again in case the size reduction helped, and publishing failed again.

The latest version is now 0.9.22, but the latest for @wp-playground/wordpress-builds is still v0.9.19.

@adamziel @bgrgicak I could use your help with this. It seems like this needs a more surgical touch, possibly even a manual update for @wp-playground/wordpress-builds, but I am not currently a collaborator on the NPM packages.

@bgrgicak
Copy link
Collaborator

@swissspidy
Copy link
Member Author

Nice, that sounds promising! 🚀

Now my only remaining ask is to add a dependencies section to https://github.com/WordPress/wordpress-playground/blob/1b438da54a998339aa42c687dff4dfbea0d72078/packages/playground/wordpress-builds/package.json, adding the @php-wasm/* dependencies. Maybe analyze this holistically for all packages.

@brandonpayton
Copy link
Member

@bgrgicak I tried that as well, but restarting the failed job doesn't seem to do anything for @wp-playground/wordpress-builds:
https://www.npmjs.com/package/@wp-playground/wordpress-builds
Screenshot 2024-07-22 at 8 18 03 AM

The latest version should be 0.9.23 to go along with the rest of the packages like:
https://www.npmjs.com/package/@wp-playground/wordpress
Screenshot 2024-07-22 at 8 19 27 AM

@adamziel
Copy link
Collaborator

@wp-playground/wordpress-builds should be a dev dependency – most packages only import it in tests, and the ones that don't are not published in npm. Currently, the list of dependencies in the published package.json is produced by this nx executor:

export default async function* packageJsonExecutor(

Ideally it would be able to distinguish between imports from .spec.ts files and the regular imports.


Aside of that, we could really use a CI job to run a smoke test on the built packages – do they import / run cleanly after building both as CJS and ESM? Here’s something related I’ve built a long time ago – I don’t think is used a lot now and then it only treats the built packages without actually linking them in another directory and running npm install to get deps as a package consumer would, but it's a start:

brandonpayton added a commit that referenced this issue Jul 22, 2024
## Motivation for the change, related issues

We are running into trouble publishing the wordpress-builds package, and
it isn't really needed to begin with.

It is big, takes time to download, and is leading to problems for our
users. Let's stop publishing the library and eliminate unintended
dependencies on it.

Related to #1630 

## Implementation details

This PR marks the `@wp-playground/wordpress-builds` package as private,
and that appears to do the trick.

## Testing Instructions (or ideally a Blueprint)

- CI
- Manually run the workflow to publish packages to NPM and retry repro
instructions from #1630 to confirm the fix
```bash
npx --yes @wp-playground/cli start
```
brandonpayton added a commit that referenced this issue Jul 22, 2024
## Motivation for the change, related issues

A couple of our NPM packages don't declare their dependencies resulting
in problems like those reported in #1630.

## Implementation details

This PR updates two NX projects to update package.json with dependencies
as part of the build process.

## Testing Instructions (or ideally a Blueprint)

- CI
brandonpayton added a commit that referenced this issue Jul 22, 2024
## Motivation for the change, related issues

The ajv library was listed as a dev dependency, but it is used by the
actual blueprints library.
Without this, consumers of the `@wp-playground/blueprints` library
encounter an error due to missing ajv lib.

```
npx --yes @wp-playground/cli start                           
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ajv' imported from /Users/brandon/src/temp/node_modules/@wp-playground/blueprints/index.js
    at new NodeError (node:internal/errors:405:5)
    at packageResolve (node:internal/modules/esm/resolve:916:9)
    at moduleResolve (node:internal/modules/esm/resolve:973:20)
    at defaultResolve (node:internal/modules/esm/resolve:1193:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}
```

Related to #1630 

## Implementation details

This PR switches `ajv` from a dev dependency to a normal dependency.

## Testing Instructions (or ideally a Blueprint)

CI
@brandonpayton
Copy link
Member

brandonpayton commented Jul 22, 2024

@swissspidy, I reviewed the other packages for other missing dependencies and fixed what I found. The dependency issues should now be fixed, at least for your use case. The following runs successfully on my machine:

% npx --yes @wp-playground/cli server
Starting a PHP server...
Setting up WordPress latest
Running the Blueprint...
Running the Blueprint – 100%
Finished running the blueprint
WordPress is running on http://127.0.0.1:9400

Does it work for you now?

@brandonpayton brandonpayton moved this from Up next to Needs Author's Reply in Playground Board Jul 22, 2024
@swissspidy
Copy link
Member Author

Yep, looks like it's working now!

@adamziel adamziel moved this from Needs Author's Reply to Inbox in Playground Board Jul 22, 2024
@github-project-automation github-project-automation bot moved this from Inbox to Done in Playground Board Jul 22, 2024
@adamziel
Copy link
Collaborator

Thank you so much @brandonpayton!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants