Skip to content

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Dec 17, 2025

Related issues

Proposed Changes

Remove PHP-WASM packages (~1.1 GB) from the desktop app's ASAR bundle. The desktop app now uses CLI for all WordPress operations, making these dependencies redundant.

  • Create local type definitions (common/types/php-versions.ts) to replace @php-wasm/universal imports
  • Remove WordPress provider abstraction layer (src/lib/wordpress-provider/)
  • Remove child process entry points from desktop build
  • Remove getProviderConstants IPC/Redux layer - components import directly from common/constants
  • Move download utilities from wp-now to src/lib/download-utils.ts
  • Remove vendor/wp-now/ directory
  • Move PHP-WASM packages from dependencies to devDependencies (for type checking only)
  • Keep forge.config.ts ignore patterns to exclude PHP-WASM from bundle

Testing Instructions

  1. npm install
  2. npm start
  3. Create a new site - verify it works
  4. Start/stop sites - verify server operations work
  5. Import/export a site - verify backup/restore works
  6. Run tests: npm test
  7. Build installer: npm run package - verify app.asar is ~295 MB

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this Dec 17, 2025
@bcotrim bcotrim changed the title remove php-wasm from Studio Remove PHP-WASM dependencies from Studio Dec 18, 2025
@bcotrim bcotrim requested review from a team and fredrikekelund December 18, 2025 09:32
@bcotrim bcotrim marked this pull request as ready for review December 18, 2025 10:33
@bcotrim bcotrim changed the base branch from trunk to dev/studio-cli-i2 December 18, 2025 15:06
@fredrikekelund
Copy link
Contributor

Let's remove the unzipper dependency from package.json as part of this PR. #2348 removed it from scripts/download-wp-server-files.ts, and the only remaining place it was used was in vendor/wp-now (which we'll remove with this PR).

Copy link
Contributor

@epeicher epeicher left a comment

Choose a reason for hiding this comment

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

Thanks @bcotrim for this huge reduction in size 🙌

I have done some initial testing, and I have identified that creating a site does not start it for me. Also, when deleting it, an error is displayed, although the deletion completes. Please see a video below.

CleanShot.2026-01-08.at.17.08.23.mp4

Please let me know if you need the logs.

@bcotrim
Copy link
Contributor Author

bcotrim commented Jan 9, 2026

@epeicher
I couldn't replicate the issue, do you see anything in the Studio logs?
Can you share a bit more detail about your test? (npm start or bundled Studio from npm run package, etc)
Thanks testing and sharing the results!

@epeicher
Copy link
Contributor

epeicher commented Jan 9, 2026

@epeicher I couldn't replicate the issue, do you see anything in the Studio logs? Can you share a bit more detail about your test? (npm start or bundled Studio from npm run package, etc) Thanks testing and sharing the results!

@bcotrim, I have been investigating more, and I have done the following that fix my issues:

  1. Delete node_modules and cli/node_modules, I have also deleted the dist folder
  2. Run npm install on the root folder to install npm packages
  3. Run cd cli && npm install to install npm packages on the cli folder
  4. On the root folder, run npm start

That fixes all the issues I was having, I am going to do some additional testing, but this looks good so far 🥳

Copy link
Contributor

@epeicher epeicher left a comment

Choose a reason for hiding this comment

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

Thanks again @bcotrim for these massive changes. I have done a round of testing, and these are my findings.

  1. Create a new site - verify it works - ✅
    This works fine, I have identified a minor issue that I am not able to reproduce in trunk but it is not a blocker, and it could be tackled as a follow-up if required. When creating a site, there is a moment where the list of sites displays the new one duplicated, please see screenshot: Image
  2. Start/stop sites - verify server operations work - ✅
  3. Export a site - verify backup works - ✅
  4. Import a site - verify restore works - ❌
    Importing a recently exported backup fails with the error Database import failed - Please find error logs here 3a0e9-pb
  5. Run tests: npm test - ✅
  6. Build installer: npm run package - verify app.asar is ~295 MB - ✅ - 294M Jan 9 13:15 app.asar (in trunk it occupies 1.4G 🤯 )

I have measured the time it takes to create a site (approximately), and I have observed that on my Mac, it takes around 16 seconds on trunk (using npm startand having a few sites) and it takes around 8 seconds on this branch, so this is a great improvement 🙌

All in all, I would like to have another pair of eyes to review the changes, but this is looking great, amazing work.

…remove-php-wasm-from-studio

# Conflicts:
#	cli/commands/site/set.ts
#	cli/commands/site/tests/set.test.ts
#	cli/lib/run-wp-cli-command.ts
#	package-lock.json
#	src/hooks/tests/use-add-site.test.tsx
#	src/hooks/use-add-site.ts
#	src/modules/add-site/components/create-site-form.tsx
#	src/modules/add-site/index.tsx
#	src/modules/site-settings/edit-site-details.tsx
#	src/site-server.ts
@bcotrim
Copy link
Contributor Author

bcotrim commented Jan 15, 2026

@fredrikekelund @epeicher with most (all?) of other on-going changes to the dev/studio-cli-i2 I updated this PR and it should be ready for another review.

@fredrikekelund
Copy link
Contributor

#2404 is already huge, so I recommend we land that PR first and then merge this PR directly to trunk.

I'm reviewing this PR now 👍

Copy link
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

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

Overall, this LGTM 👍 Nice work, @bcotrim!

The one thing we should look into before merging is the function for checking the current WP-CLI version. We'll need a different approach there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use this function in scripts/download-node-binary.mjs, too?

In the future, we might consider also targeting src/lib/import-export/import/handlers/backup-handler-zip.ts, but that's for another PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we import these directly from @wp-playground/blueprints?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the extractZip function from common here?

Comment on lines +13 to +28
/**
* Get a temporary path for tests
*/
function getTmpPath( subfolder: string ): string {
return path.join( os.tmpdir(), `studio-tests-${ subfolder }` );
}

/**
* Get the base path for server files (WordPress versions, SQLite, etc.)
*/
function getBasePath(): string {
if ( process.env.NODE_ENV === 'test' ) {
return getTmpPath( 'server-files' );
}
return getServerFilesPath();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The big reason for having this extra layer on top of src/storage/paths is that we add getTmpPath, right? How necessary is that?

};
start( siteId?: string ): Promise< void >;
stop(): Promise< void >;
runPhp( data: { code: string; [ key: string ]: unknown } ): Promise< string >;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
runPhp( data: { code: string; [ key: string ]: unknown } ): Promise< string >;

Can't we just remove the runPhp method now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we now have just a single class implementing this interface, I'm wondering if we really need it..?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking forward to the day when we've consolidated this type of functionality in the CLI…

Comment on lines 138 to 157
async function getWPCliVersionFromInstallation(): Promise< string > {
return new Promise( ( resolve ) => {
const [ emitter ] = executeCliCommand( [ 'wp', '--path', getWpCliFolderPath(), '--version' ], {
output: 'capture',
} );

emitter.on( 'success', ( { result } ) => {
const stdout = result?.stdout || '';
if ( stdout.startsWith( 'WP-CLI ' ) ) {
const version = stdout.split( ' ' )[ 1 ];
resolve( version ? `v${ version }` : '' );
} else {
resolve( '' );
}
} );

emitter.on( 'failure', () => resolve( '' ) );
emitter.on( 'error', () => resolve( '' ) );
} );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work. The --path argument is parsed by the Studio CLI and must point to a site directory.

Off the top of my head, the best way to resolve this might be to add a hidden --no-path option to the wp command. Thoughts, @bcotrim?

@wojtekn
Copy link
Contributor

wojtekn commented Jan 16, 2026

@bcotrim "Size reduction:" is a bit misleading as it compares cleanup with the cli-i2 branch.

1.6.8 is ~1.8 GB, so there is no reduction when compared to base brach.

Base automatically changed from dev/studio-cli-i2 to trunk January 16, 2026 10:35
@fredrikekelund
Copy link
Contributor

there is no reduction when compared to base brach.

This was our original goal. The fact that we've added a new bundled node runtime since @bcotrim opened this PR will impact the installer size, and we expect it to be slightly larger than 1.6.8.

But yeah, even if the PR description might lead one to believe that this change reduces the installer filesize, we are really just keeping it in check 👍

@wojtekn
Copy link
Contributor

wojtekn commented Jan 16, 2026

@fredrikekelund, it's okay. I just wanted to clarify this to ensure the reader doesn't think this cleanup provides size reduction for the app.

Copy link
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

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

LGTM 👍 There are still a couple of comments from my previous review that I'd love to discuss, but they're no blockers.

Let's move ahead with landing this

@fredrikekelund
Copy link
Contributor

For the record, the reason I made the --studio-no-path change in 78015d0 was that TS complained locally about overriding the path option type (despite CI passing for some unclear reason 🤔)

@bcotrim
Copy link
Contributor Author

bcotrim commented Jan 16, 2026

@bcotrim "Size reduction:" is a bit misleading as it compares cleanup with the cli-i2 branch.

1.6.8 is ~1.8 GB, so there is no reduction when compared to base brach.

Thanks for pointing it out! I Removed it, since it no longer makes sense

@wpmobilebot
Copy link

📊 Performance Test Results

Comparing 7111f6a vs trunk

site-editor

Metric trunk 7111f6a Diff Change
load 2899.00 ms 2895.00 ms -4.00 ms 🟢 -0.1%

site-startup

Metric trunk 7111f6a Diff Change
siteCreation 7075.00 ms 7075.00 ms 0.00 ms ⚪ 0.0%
siteStartup 3947.00 ms 3942.00 ms -5.00 ms 🟢 -0.1%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@bcotrim bcotrim merged commit 307691d into trunk Jan 16, 2026
9 checks passed
@bcotrim bcotrim deleted the stu-960-remove-php-wasm-from-studio branch January 16, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants