From b1b73f929b1d05d38bec80ad8bafecb617c96c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Wed, 9 Oct 2024 21:28:03 +0200 Subject: [PATCH] PHP.wasm: Load correct php.wasm paths in the built Node.js packages 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`. --- .../{public => }/asyncify/7_0_33/php_7_0.wasm | Bin .../{public => }/asyncify/7_1_30/php_7_1.wasm | Bin .../{public => }/asyncify/7_2_34/php_7_2.wasm | Bin .../{public => }/asyncify/7_3_33/php_7_3.wasm | Bin .../{public => }/asyncify/7_4_33/php_7_4.wasm | Bin .../{public => }/asyncify/8_0_30/php_8_0.wasm | Bin .../{public => }/asyncify/8_1_23/php_8_1.wasm | Bin .../{public => }/asyncify/8_2_10/php_8_2.wasm | Bin .../{public => }/asyncify/8_3_0/php_8_3.wasm | Bin .../node/{public => }/asyncify/php_7_0.js | 0 .../node/{public => }/asyncify/php_7_1.js | 0 .../node/{public => }/asyncify/php_7_2.js | 0 .../node/{public => }/asyncify/php_7_3.js | 0 .../node/{public => }/asyncify/php_7_4.js | 0 .../node/{public => }/asyncify/php_8_0.js | 0 .../node/{public => }/asyncify/php_8_1.js | 0 .../node/{public => }/asyncify/php_8_2.js | 0 .../node/{public => }/asyncify/php_8_3.js | 0 packages/php-wasm/node/build.js | 45 ++++++++++++++++++ .../{public => }/jspi/7_0_33/php_7_0.wasm | Bin .../{public => }/jspi/7_1_30/php_7_1.wasm | Bin .../{public => }/jspi/7_2_34/php_7_2.wasm | Bin .../{public => }/jspi/7_3_33/php_7_3.wasm | Bin .../{public => }/jspi/7_4_33/php_7_4.wasm | Bin .../{public => }/jspi/8_0_30/php_8_0.wasm | Bin .../{public => }/jspi/8_1_23/php_8_1.wasm | Bin .../{public => }/jspi/8_2_10/php_8_2.wasm | Bin .../node/{public => }/jspi/8_3_0/php_8_3.wasm | Bin .../node/{public => }/jspi/php_7_0.js | 0 .../node/{public => }/jspi/php_7_1.js | 0 .../node/{public => }/jspi/php_7_2.js | 0 .../node/{public => }/jspi/php_7_3.js | 0 .../node/{public => }/jspi/php_7_4.js | 0 .../node/{public => }/jspi/php_8_0.js | 0 .../node/{public => }/jspi/php_8_1.js | 0 .../node/{public => }/jspi/php_8_2.js | 0 .../node/{public => }/jspi/php_8_3.js | 0 packages/php-wasm/node/project.json | 45 +++++++++--------- .../node/src/lib/get-php-loader-module.ts | 36 +++++++------- 39 files changed, 85 insertions(+), 41 deletions(-) rename packages/php-wasm/node/{public => }/asyncify/7_0_33/php_7_0.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/7_1_30/php_7_1.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/7_2_34/php_7_2.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/7_3_33/php_7_3.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/7_4_33/php_7_4.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/8_0_30/php_8_0.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/8_1_23/php_8_1.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/8_2_10/php_8_2.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/8_3_0/php_8_3.wasm (100%) rename packages/php-wasm/node/{public => }/asyncify/php_7_0.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_7_1.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_7_2.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_7_3.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_7_4.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_8_0.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_8_1.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_8_2.js (100%) rename packages/php-wasm/node/{public => }/asyncify/php_8_3.js (100%) rename packages/php-wasm/node/{public => }/jspi/7_0_33/php_7_0.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/7_1_30/php_7_1.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/7_2_34/php_7_2.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/7_3_33/php_7_3.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/7_4_33/php_7_4.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/8_0_30/php_8_0.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/8_1_23/php_8_1.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/8_2_10/php_8_2.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/8_3_0/php_8_3.wasm (100%) rename packages/php-wasm/node/{public => }/jspi/php_7_0.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_7_1.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_7_2.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_7_3.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_7_4.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_8_0.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_8_1.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_8_2.js (100%) rename packages/php-wasm/node/{public => }/jspi/php_8_3.js (100%) diff --git a/packages/php-wasm/node/public/asyncify/7_0_33/php_7_0.wasm b/packages/php-wasm/node/asyncify/7_0_33/php_7_0.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/7_0_33/php_7_0.wasm rename to packages/php-wasm/node/asyncify/7_0_33/php_7_0.wasm diff --git a/packages/php-wasm/node/public/asyncify/7_1_30/php_7_1.wasm b/packages/php-wasm/node/asyncify/7_1_30/php_7_1.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/7_1_30/php_7_1.wasm rename to packages/php-wasm/node/asyncify/7_1_30/php_7_1.wasm diff --git a/packages/php-wasm/node/public/asyncify/7_2_34/php_7_2.wasm b/packages/php-wasm/node/asyncify/7_2_34/php_7_2.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/7_2_34/php_7_2.wasm rename to packages/php-wasm/node/asyncify/7_2_34/php_7_2.wasm diff --git a/packages/php-wasm/node/public/asyncify/7_3_33/php_7_3.wasm b/packages/php-wasm/node/asyncify/7_3_33/php_7_3.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/7_3_33/php_7_3.wasm rename to packages/php-wasm/node/asyncify/7_3_33/php_7_3.wasm diff --git a/packages/php-wasm/node/public/asyncify/7_4_33/php_7_4.wasm b/packages/php-wasm/node/asyncify/7_4_33/php_7_4.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/7_4_33/php_7_4.wasm rename to packages/php-wasm/node/asyncify/7_4_33/php_7_4.wasm diff --git a/packages/php-wasm/node/public/asyncify/8_0_30/php_8_0.wasm b/packages/php-wasm/node/asyncify/8_0_30/php_8_0.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/8_0_30/php_8_0.wasm rename to packages/php-wasm/node/asyncify/8_0_30/php_8_0.wasm diff --git a/packages/php-wasm/node/public/asyncify/8_1_23/php_8_1.wasm b/packages/php-wasm/node/asyncify/8_1_23/php_8_1.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/8_1_23/php_8_1.wasm rename to packages/php-wasm/node/asyncify/8_1_23/php_8_1.wasm diff --git a/packages/php-wasm/node/public/asyncify/8_2_10/php_8_2.wasm b/packages/php-wasm/node/asyncify/8_2_10/php_8_2.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/8_2_10/php_8_2.wasm rename to packages/php-wasm/node/asyncify/8_2_10/php_8_2.wasm diff --git a/packages/php-wasm/node/public/asyncify/8_3_0/php_8_3.wasm b/packages/php-wasm/node/asyncify/8_3_0/php_8_3.wasm similarity index 100% rename from packages/php-wasm/node/public/asyncify/8_3_0/php_8_3.wasm rename to packages/php-wasm/node/asyncify/8_3_0/php_8_3.wasm diff --git a/packages/php-wasm/node/public/asyncify/php_7_0.js b/packages/php-wasm/node/asyncify/php_7_0.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_7_0.js rename to packages/php-wasm/node/asyncify/php_7_0.js diff --git a/packages/php-wasm/node/public/asyncify/php_7_1.js b/packages/php-wasm/node/asyncify/php_7_1.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_7_1.js rename to packages/php-wasm/node/asyncify/php_7_1.js diff --git a/packages/php-wasm/node/public/asyncify/php_7_2.js b/packages/php-wasm/node/asyncify/php_7_2.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_7_2.js rename to packages/php-wasm/node/asyncify/php_7_2.js diff --git a/packages/php-wasm/node/public/asyncify/php_7_3.js b/packages/php-wasm/node/asyncify/php_7_3.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_7_3.js rename to packages/php-wasm/node/asyncify/php_7_3.js diff --git a/packages/php-wasm/node/public/asyncify/php_7_4.js b/packages/php-wasm/node/asyncify/php_7_4.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_7_4.js rename to packages/php-wasm/node/asyncify/php_7_4.js diff --git a/packages/php-wasm/node/public/asyncify/php_8_0.js b/packages/php-wasm/node/asyncify/php_8_0.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_8_0.js rename to packages/php-wasm/node/asyncify/php_8_0.js diff --git a/packages/php-wasm/node/public/asyncify/php_8_1.js b/packages/php-wasm/node/asyncify/php_8_1.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_8_1.js rename to packages/php-wasm/node/asyncify/php_8_1.js diff --git a/packages/php-wasm/node/public/asyncify/php_8_2.js b/packages/php-wasm/node/asyncify/php_8_2.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_8_2.js rename to packages/php-wasm/node/asyncify/php_8_2.js diff --git a/packages/php-wasm/node/public/asyncify/php_8_3.js b/packages/php-wasm/node/asyncify/php_8_3.js similarity index 100% rename from packages/php-wasm/node/public/asyncify/php_8_3.js rename to packages/php-wasm/node/asyncify/php_8_3.js diff --git a/packages/php-wasm/node/build.js b/packages/php-wasm/node/build.js index 8890448109..fbf8dff48f 100644 --- a/packages/php-wasm/node/build.js +++ b/packages/php-wasm/node/build.js @@ -8,6 +8,49 @@ try { // Ignore } +/** + * This is a naive, best effort dirname/filename replacement plugin. + * + * 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. + * + * @param {string} dirnameReplacement + * @param {string} filenameReplacement + * @returns + */ +const dirnamePlugin = { + name: 'dirname', + setup(build) { + build.onLoad({ filter: /\/php_\d+_\d+\.js$/ }, ({ path: filePath }) => { + if (!filePath.match(/node_modules/)) { + let contents = fs.readFileSync(filePath, 'utf8'); + const loader = path.extname(filePath).substring(1); + const dirname = filePath.includes('/jspi/') + ? 'jspi' + : 'asyncify'; + contents = contents.replaceAll( + '__dirname', + `__dirname + ${JSON.stringify(dirname)}` + ); + return { + contents, + loader, + }; + } + }); + }, +}; + async function build() { await esbuild.build({ entryPoints: [ @@ -34,6 +77,7 @@ async function build() { '.ini': 'file', '.wasm': 'file', }, + plugins: [dirnamePlugin], }); await esbuild.build({ @@ -69,6 +113,7 @@ const __filename = new URL(import.meta.url).pathname; '.ini': 'file', '.wasm': 'file', }, + plugins: [dirnamePlugin], }); fs.copyFileSync( diff --git a/packages/php-wasm/node/public/jspi/7_0_33/php_7_0.wasm b/packages/php-wasm/node/jspi/7_0_33/php_7_0.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/7_0_33/php_7_0.wasm rename to packages/php-wasm/node/jspi/7_0_33/php_7_0.wasm diff --git a/packages/php-wasm/node/public/jspi/7_1_30/php_7_1.wasm b/packages/php-wasm/node/jspi/7_1_30/php_7_1.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/7_1_30/php_7_1.wasm rename to packages/php-wasm/node/jspi/7_1_30/php_7_1.wasm diff --git a/packages/php-wasm/node/public/jspi/7_2_34/php_7_2.wasm b/packages/php-wasm/node/jspi/7_2_34/php_7_2.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/7_2_34/php_7_2.wasm rename to packages/php-wasm/node/jspi/7_2_34/php_7_2.wasm diff --git a/packages/php-wasm/node/public/jspi/7_3_33/php_7_3.wasm b/packages/php-wasm/node/jspi/7_3_33/php_7_3.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/7_3_33/php_7_3.wasm rename to packages/php-wasm/node/jspi/7_3_33/php_7_3.wasm diff --git a/packages/php-wasm/node/public/jspi/7_4_33/php_7_4.wasm b/packages/php-wasm/node/jspi/7_4_33/php_7_4.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/7_4_33/php_7_4.wasm rename to packages/php-wasm/node/jspi/7_4_33/php_7_4.wasm diff --git a/packages/php-wasm/node/public/jspi/8_0_30/php_8_0.wasm b/packages/php-wasm/node/jspi/8_0_30/php_8_0.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/8_0_30/php_8_0.wasm rename to packages/php-wasm/node/jspi/8_0_30/php_8_0.wasm diff --git a/packages/php-wasm/node/public/jspi/8_1_23/php_8_1.wasm b/packages/php-wasm/node/jspi/8_1_23/php_8_1.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/8_1_23/php_8_1.wasm rename to packages/php-wasm/node/jspi/8_1_23/php_8_1.wasm diff --git a/packages/php-wasm/node/public/jspi/8_2_10/php_8_2.wasm b/packages/php-wasm/node/jspi/8_2_10/php_8_2.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/8_2_10/php_8_2.wasm rename to packages/php-wasm/node/jspi/8_2_10/php_8_2.wasm diff --git a/packages/php-wasm/node/public/jspi/8_3_0/php_8_3.wasm b/packages/php-wasm/node/jspi/8_3_0/php_8_3.wasm similarity index 100% rename from packages/php-wasm/node/public/jspi/8_3_0/php_8_3.wasm rename to packages/php-wasm/node/jspi/8_3_0/php_8_3.wasm diff --git a/packages/php-wasm/node/public/jspi/php_7_0.js b/packages/php-wasm/node/jspi/php_7_0.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_7_0.js rename to packages/php-wasm/node/jspi/php_7_0.js diff --git a/packages/php-wasm/node/public/jspi/php_7_1.js b/packages/php-wasm/node/jspi/php_7_1.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_7_1.js rename to packages/php-wasm/node/jspi/php_7_1.js diff --git a/packages/php-wasm/node/public/jspi/php_7_2.js b/packages/php-wasm/node/jspi/php_7_2.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_7_2.js rename to packages/php-wasm/node/jspi/php_7_2.js diff --git a/packages/php-wasm/node/public/jspi/php_7_3.js b/packages/php-wasm/node/jspi/php_7_3.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_7_3.js rename to packages/php-wasm/node/jspi/php_7_3.js diff --git a/packages/php-wasm/node/public/jspi/php_7_4.js b/packages/php-wasm/node/jspi/php_7_4.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_7_4.js rename to packages/php-wasm/node/jspi/php_7_4.js diff --git a/packages/php-wasm/node/public/jspi/php_8_0.js b/packages/php-wasm/node/jspi/php_8_0.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_8_0.js rename to packages/php-wasm/node/jspi/php_8_0.js diff --git a/packages/php-wasm/node/public/jspi/php_8_1.js b/packages/php-wasm/node/jspi/php_8_1.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_8_1.js rename to packages/php-wasm/node/jspi/php_8_1.js diff --git a/packages/php-wasm/node/public/jspi/php_8_2.js b/packages/php-wasm/node/jspi/php_8_2.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_8_2.js rename to packages/php-wasm/node/jspi/php_8_2.js diff --git a/packages/php-wasm/node/public/jspi/php_8_3.js b/packages/php-wasm/node/jspi/php_8_3.js similarity index 100% rename from packages/php-wasm/node/public/jspi/php_8_3.js rename to packages/php-wasm/node/jspi/php_8_3.js diff --git a/packages/php-wasm/node/project.json b/packages/php-wasm/node/project.json index ff15e431a8..03025792ad 100644 --- a/packages/php-wasm/node/project.json +++ b/packages/php-wasm/node/project.json @@ -22,7 +22,8 @@ "executor": "nx:run-commands", "options": { "commands": [ - "cp -rf packages/php-wasm/node/public/* dist/packages/php-wasm/node" + "cp -rf packages/php-wasm/node/jspi dist/packages/php-wasm/node", + "cp -rf packages/php-wasm/node/asyncify dist/packages/php-wasm/node" ], "parallel": false }, @@ -50,8 +51,6 @@ "dependsOn": ["build:copy-wasms"] }, "build:bundle": { - "executor": "@nx/esbuild:esbuild", - "outputs": ["dist/packages/php-wasm/node"], "executor": "nx:run-commands", "options": { "command": "node packages/php-wasm/node/build.js", @@ -80,7 +79,7 @@ "executor": "nx:run-commands", "options": { "commands": [ - "node packages/php-wasm/compile/build.js --PLATFORM=node --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes" + "node packages/php-wasm/compile/build.js --PLATFORM=node --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes" ], "parallel": false } @@ -89,15 +88,15 @@ "executor": "nx:run-commands", "options": { "commands": [ - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.3 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.2 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.1 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.0 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.4 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.3 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.2 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.1 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.0 --output-dir=packages/php-wasm/node/public/jspi --WITH_JSPI=yes" + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.3 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.2 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.1 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.0 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.4 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.3 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.2 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.1 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.0 --output-dir=packages/php-wasm/node/jspi --WITH_JSPI=yes" ], "parallel": false } @@ -106,7 +105,7 @@ "executor": "nx:run-commands", "options": { "commands": [ - "node packages/php-wasm/compile/build.js --PLATFORM=node --output-dir=packages/php-wasm/node/public/asyncify" + "node packages/php-wasm/compile/build.js --PLATFORM=node --output-dir=packages/php-wasm/node/asyncify" ], "parallel": false } @@ -115,15 +114,15 @@ "executor": "nx:run-commands", "options": { "commands": [ - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.3 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.2 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.1 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.0 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.4 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.3 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.2 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.1 --output-dir=packages/php-wasm/node/public/asyncify", - "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.0 --output-dir=packages/php-wasm/node/public/asyncify" + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.3 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.2 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.1 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=8.0 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.4 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.3 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.2 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.1 --output-dir=packages/php-wasm/node/asyncify", + "node packages/php-wasm/compile/build.js --PLATFORM=node --PHP_VERSION=7.0 --output-dir=packages/php-wasm/node/asyncify" ], "parallel": false } diff --git a/packages/php-wasm/node/src/lib/get-php-loader-module.ts b/packages/php-wasm/node/src/lib/get-php-loader-module.ts index 27676bf96c..6ebbe6a7e9 100644 --- a/packages/php-wasm/node/src/lib/get-php-loader-module.ts +++ b/packages/php-wasm/node/src/lib/get-php-loader-module.ts @@ -9,61 +9,61 @@ export async function getPHPLoaderModule( switch (version) { case '8.3': // @ts-ignore - return await import(`../../public/jspi/php_8_3.js`); + return await import(`../../jspi/php_8_3.js`); case '8.2': // @ts-ignore - return await import(`../../public/jspi/php_8_2.js`); + return await import(`../../jspi/php_8_2.js`); case '8.1': // @ts-ignore - return await import(`../../public/jspi/php_8_1.js`); + return await import(`../../jspi/php_8_1.js`); case '8.0': // @ts-ignore - return await import(`../../public/jspi/php_8_0.js`); + return await import(`../../jspi/php_8_0.js`); case '7.4': // @ts-ignore - return await import(`../../public/jspi/php_7_4.js`); + return await import(`../../jspi/php_7_4.js`); case '7.3': // @ts-ignore - return await import(`../../public/jspi/php_7_3.js`); + return await import(`../../jspi/php_7_3.js`); case '7.2': // @ts-ignore - return await import(`../../public/jspi/php_7_2.js`); + return await import(`../../jspi/php_7_2.js`); case '7.1': // @ts-ignore - return await import(`../../public/jspi/php_7_1.js`); + return await import(`../../jspi/php_7_1.js`); case '7.0': // @ts-ignore - return await import(`../../public/jspi/php_7_0.js`); + return await import(`../../jspi/php_7_0.js`); } } else { switch (version) { case '8.3': // @ts-ignore - return await import(`../../public/asyncify/php_8_3.js`); + return await import(`../../asyncify/php_8_3.js`); case '8.2': // @ts-ignore - return await import(`../../public/asyncify/php_8_2.js`); + return await import(`../../asyncify/php_8_2.js`); case '8.1': // @ts-ignore - return await import(`../../public/asyncify/php_8_1.js`); + return await import(`../../asyncify/php_8_1.js`); case '8.0': // @ts-ignore - return await import(`../../public/asyncify/php_8_0.js`); + return await import(`../../asyncify/php_8_0.js`); case '7.4': // @ts-ignore - return await import(`../../public/asyncify/php_7_4.js`); + return await import(`../../asyncify/php_7_4.js`); case '7.3': // @ts-ignore - return await import(`../../public/asyncify/php_7_3.js`); + return await import(`../../asyncify/php_7_3.js`); case '7.2': // @ts-ignore - return await import(`../../public/asyncify/php_7_2.js`); + return await import(`../../asyncify/php_7_2.js`); case '7.1': // @ts-ignore - return await import(`../../public/asyncify/php_7_1.js`); + return await import(`../../asyncify/php_7_1.js`); case '7.0': // @ts-ignore - return await import(`../../public/asyncify/php_7_0.js`); + return await import(`../../asyncify/php_7_0.js`); } } throw new Error(`Unsupported PHP version ${version}`);