Closed markhowellsmead closed 1 year ago
The environment does not seem relevant here. Typically an error with the Peast scanner indicates an issue with parsing JavaScript files, for which we'd have to file an issue upstream in the Peast repository.
Does the error still occur when you run wp i18n make-pot . languages/shp_gantrisch_adb.pot --skip-js
? If not, then you'll need to find the offending JS file / function and ideally share it here for further debugging.
Thanks for the swift response @swissspidy. Excluding JS files stops the error from occurring. I'll look into that further.
I've tracked it down in one project to a piece of code where I'm using useState
from the @wordpress/elements
package. (The code is compiled to JS using this Webpack task.)
const [processing, setProcessing] = useState(null);
…Various code…
if(condition){
setProcessing(true);
}
If I comment out this single instance of setProcessing(true);
and recompile my JS, then the POT can be created. If not, then it throws the long error message.
Cool, then I recommend opening an issue at https://github.com/mck89/peast with this minimal code to reproduce so that it can be fixed there.
@markhowellsmead FWIW, that code is not it.
If I test with Peast myself:
<?php
require_once "vendor/autoload.php";
$source = <<<'JS'
const [processing, setProcessing] = useState(null);
// …Various code…
if(condition){
setProcessing(true);
}
JS;
$ast = Peast\Peast::latest($source, $options)->parse(); //Parse it!
var_dump($ast);
This throws no error.
If the compiled code is throwing errors, you need to share the compiled code.
But again, I recommend opening an issue on the Peast repo yourself.
(The code is compiled to JS using this Webpack task.)
FWIW this repo is not public.
> But again, I recommend opening an issue on the Peast repo yourself.
I will as soon as I get time.
(The code is compiled to JS using this Webpack task.)
FWIW this repo is not public.
Sorry: it's public now.
Response is that they can't help with the bug. See https://github.com/mck89/peast/issues/54#issuecomment-1342648900.
The code you shared at https://github.com/mck89/peast/issues/54#issuecomment-1339532089 is not causing any errors for me either, so that response is understandable. Both Peast itself (using the approach shared above) and wp i18n make-pot
parse that code without issues.
In other words, I cannot reproduce the issue with the code you shared.
Bug Report
Describe the current, buggy behavior
When running
wp i18n make-pot . languages/shp_gantrisch_adb.pot
on the command line in a site shell from the Local app on Mac OSX, a very long error message is generated. The initial message isWarning: Uncaught Error in exception handling during call to Error::__toString() in phar:///Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/wp-cli.phar/vendor/mck89/peast/lib/Peast/Syntax/Scanner.php on line 0
Describe how other contributors can replicate this bug Run
wp i18n make-pot . languages/shp_gantrisch_adb.pot
on the command line in a site shell from the Local app on Mac OSX.Describe what you would expect as the correct outcome
The POT file be generated without any error messages.
Let us know what environment you are running this on