diff --git a/packages/testing-php/src/php-runtime-factory.ts b/packages/testing-php/src/php-runtime-factory.ts index eaab303..8ee961a 100644 --- a/packages/testing-php/src/php-runtime-factory.ts +++ b/packages/testing-php/src/php-runtime-factory.ts @@ -1,5 +1,12 @@ import { WebPHP } from "@php-wasm/web"; +// @ts-expect-error hack +import * as phpModule from "@php-wasm/web/light/php_8_3.js"; import { version } from "./version"; -export const phpRuntimeFactory = () => WebPHP.loadRuntime(version); +export const phpRuntimeFactory = () => + WebPHP.loadRuntime(version, { + onPhpLoaderModuleLoaded(loader) { + Object.assign(loader, phpModule) + }, + }); diff --git a/packages/testing-php/vite.config.js b/packages/testing-php/vite.config.js index cd1e3f3..ad97fe4 100644 --- a/packages/testing-php/vite.config.js +++ b/packages/testing-php/vite.config.js @@ -39,6 +39,16 @@ export default defineConfig({ } }, }, + { + name: "transform-php-imports", + transform(code, id) { + if (id.includes("@php-wasm/web/index.js")) { + return { + code: code.replace(/await import\(".*php_\d_\d\.js"\)/g, "{}"), + }; + } + }, + }, dts({ rollupTypes: true, }),