-
Notifications
You must be signed in to change notification settings - Fork 382
[PHP] Fix external dynamic imports issue in PHP.wasm Web #3093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
@bgrgicak Sorry for the mistake. I should find a way to add a test for this but at the moment it crashes |
|
@mho22 how can this error be reproduced? I enabled the "intl" in a test site Blueprint and am not encountering any error? |
|
@brandonpayton This is probably why we didn't catch it as soon as the new packages were released. Here is a test project :
{
"type": "module",
"dependencies": {
"@php-wasm/web": "^3.0.39",
"vite": "^7.3.0"
},
"scripts": {
"dev": "vite"
}
}
import { defineConfig } from 'vite';
export default defineConfig( {
assetsInclude: [/\.dat$/, /\.wasm$/, /\.so$/, /\.la$/],
optimizeDeps : {
esbuildOptions : {
loader : {
'.dat': 'text',
'.wasm': 'text',
'.so': 'text',
'.la': 'text',
}
}
}
} );
<!DOCTYPE html>
<html>
<head>
<script type="module" src="script.js"></script>
</head>
<body>
</body>
</html>
import { PHP } from '@php-wasm/universal';
import { loadWebRuntime } from "@php-wasm/web";
const php = new PHP( await loadWebRuntime( '8.4' ) );
const response = await php.runStream( { code : `<?php echo "Hello World";` } );
console.log( await response.stdoutText );Then run It then returns : |
Thanks, @mho22, that helps! |
Motivation for the change, related issues
Fixing follow-up issue #3085
I previously removed the Vite extension for External Dynamic Imports thinking it was no longer necessary to fix the issue initiated by the per-PHP-package split pull request. I was wrong. This pull request re-creates the plugin but modifies the behavior to fix the current issue.
The current issue returns this :
Implementation details
Re-create the
vite-external-dynamic-importsfile but :Testing Instructions (or ideally a Blueprint)
CI