Skip to content

Commit

Permalink
Fix php runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
x0k committed Jun 15, 2024
1 parent cb39d37 commit 4bee655
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/testing-php/src/php-runtime-factory.ts
Original file line number Diff line number Diff line change
@@ -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)
},
});
10 changes: 10 additions & 0 deletions packages/testing-php/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down

0 comments on commit 4bee655

Please sign in to comment.