Skip to content

Commit

Permalink
PHP.wasm: Load correct php.wasm paths in the built Node.js packages
Browse files Browse the repository at this point in the history
 Gets `@php-wasm/node` and all the other CLI packages to load the .wasm
 binaries from the correct path after #1867 introduced JSPI and #1873 made
 it pass all the tests in Node.js

 ## Technical details

In the repo, php.js files are stored in php_wasm/node/jspi or php_wasm/node/asyncify.
 They start with a line like this:

 const dependencyFilename = __dirname + '/8_0_30/php_8_0.wasm';

 After the build, the contents are concatenated into a single file, which
 breaks the dependencyFilename variable. This plugin corrects that by
 replacing __dirname with the correct value such as 'jspi' or 'asyncify'.

 The implementation is naive and assumes the substrings __dirname is only used
 as a variable, are not a part of any other name, and is not seen in any string
 literals.

 ## Test plan

Build the production packages with `nx build php-wasm-node` and run the
PHP CLI package to confirm it doesn't crash. I couldn't get npm link to
work so I created a `dist/packages/php-wasm/node_modules/@php-wasm`
directory and linked all the built packages there with `ln -s`.
  • Loading branch information
adamziel committed Oct 9, 2024
1 parent 09343bc commit b1b73f9
Show file tree
Hide file tree
Showing 39 changed files with 85 additions and 41 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions packages/php-wasm/node/build.js
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 22 additions & 23 deletions packages/php-wasm/node/project.json
36 changes: 18 additions & 18 deletions packages/php-wasm/node/src/lib/get-php-loader-module.ts

0 comments on commit b1b73f9

Please sign in to comment.