Fix code quality violations and add VS Code extension features
Fix VS Code extension storage paths for new directory structure Fix jqhtml compiled files missing from bundle Fix bundle babel transformation and add rsxrealpath() function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -89,6 +89,12 @@ class BundleCompiler
|
||||
*/
|
||||
protected array $jqhtml_compiled_files = [];
|
||||
|
||||
/**
|
||||
* Mapping from babel-transformed files to their original source files
|
||||
* ['storage/rsx-tmp/babel_xxx.js' => 'app/RSpade/Core/Js/SomeFile.js']
|
||||
*/
|
||||
protected array $babel_file_mapping = [];
|
||||
|
||||
/**
|
||||
* Compile a bundle
|
||||
*/
|
||||
@@ -607,7 +613,8 @@ class BundleCompiler
|
||||
*/
|
||||
protected function _add_file(string $path): void
|
||||
{
|
||||
$normalized = realpath($path);
|
||||
$normalized = rsxrealpath($path);
|
||||
|
||||
if (!$normalized) {
|
||||
return;
|
||||
}
|
||||
@@ -694,7 +701,7 @@ class BundleCompiler
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile()) {
|
||||
$normalized = realpath($file->getPathname());
|
||||
$normalized = rsxrealpath($file->getPathname());
|
||||
if (!isset($this->included_files[$normalized])) {
|
||||
if (!isset($this->watch_files['all'])) {
|
||||
$this->watch_files['all'] = [];
|
||||
@@ -977,6 +984,8 @@ class BundleCompiler
|
||||
*/
|
||||
protected function _order_javascript_files_by_dependency(array $js_files): array
|
||||
{
|
||||
console_debug('BUNDLE_SORT', 'Starting dependency sort with ' . count($js_files) . ' files');
|
||||
|
||||
$manifest = Manifest::get_full_manifest();
|
||||
$manifest_files = $manifest['data']['files'] ?? [];
|
||||
|
||||
@@ -994,7 +1003,8 @@ class BundleCompiler
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip other temp files (they won't be in the manifest)
|
||||
// Skip ALL temp files - they won't be in manifest
|
||||
// Babel and other transformations should have been applied to original files
|
||||
if (str_contains($file, 'storage/rsx-tmp/')) {
|
||||
$non_class_files[] = $file;
|
||||
continue;
|
||||
@@ -1278,24 +1288,26 @@ implode("\n", array_map(fn ($f) => ' - ' . str_replace(base_path() . '/', '',
|
||||
};
|
||||
|
||||
// Process all class files
|
||||
try {
|
||||
foreach ($class_files as $file) {
|
||||
if (!isset($visited[$file])) {
|
||||
$visit($file);
|
||||
$visit($file); //??
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException $e) {
|
||||
// Re-throw with bundle context if available
|
||||
if (!empty($this->bundle_class)) {
|
||||
throw new RuntimeException(
|
||||
"Bundle compilation failed for {$this->bundle_class}:\n" . $e->getMessage(),
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
// try {
|
||||
// (code above was here)
|
||||
// } catch (RuntimeException $e) {
|
||||
// // Re-throw with bundle context if available
|
||||
// if (!empty($this->bundle_class)) {
|
||||
// throw new RuntimeException(
|
||||
// "Bundle compilation failed for {$this->bundle_class}:\n" . $e->getMessage(),
|
||||
// 0,
|
||||
// $e
|
||||
// );
|
||||
// }
|
||||
|
||||
// throw $e;
|
||||
// }
|
||||
|
||||
return $sorted;
|
||||
}
|
||||
@@ -1744,12 +1756,12 @@ implode("\n", array_map(fn ($f) => ' - ' . str_replace(base_path() . '/', '',
|
||||
|
||||
if ($babel_enabled && $decorators_enabled) {
|
||||
// Use the JavaScript Transformer to transpile files with decorators
|
||||
$transformed_files = [];
|
||||
// IMPORTANT: We populate $babel_file_mapping but DON'T modify $files array
|
||||
// This preserves dependency sort order - we substitute babel versions during concat
|
||||
|
||||
foreach ($files as $file) {
|
||||
// Skip temp files and already processed files
|
||||
if (str_contains($file, 'storage/rsx-tmp/') || str_contains($file, 'storage/rsx-build/')) {
|
||||
$transformed_files[] = $file;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1757,11 +1769,13 @@ implode("\n", array_map(fn ($f) => ' - ' . str_replace(base_path() . '/', '',
|
||||
try {
|
||||
$transformed_code = \App\RSpade\Core\JavaScript\Js_Transformer::transform($file);
|
||||
|
||||
// Write transformed code to a temp file for concatenation
|
||||
// Write transformed code to a temp file
|
||||
$temp_file = storage_path('rsx-tmp/babel_' . md5($file) . '_' . uniqid() . '.js');
|
||||
file_put_contents($temp_file, $transformed_code);
|
||||
|
||||
$transformed_files[] = $temp_file;
|
||||
// Store mapping: original file => babel file
|
||||
// During concatenation we'll use the babel version
|
||||
$this->babel_file_mapping[$file] = $temp_file;
|
||||
console_debug('BUNDLE', 'Transformed ' . str_replace(base_path() . '/', '', $file));
|
||||
} catch (Exception $e) {
|
||||
// FAIL LOUD - Never allow untransformed decorators through
|
||||
@@ -1773,8 +1787,6 @@ implode("\n", array_map(fn ($f) => ' - ' . str_replace(base_path() . '/', '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$files = $transformed_files;
|
||||
}
|
||||
|
||||
// Add all the JS files
|
||||
@@ -1791,7 +1803,9 @@ implode("\n", array_map(fn ($f) => ' - ' . str_replace(base_path() . '/', '',
|
||||
escapeshellarg($output_file),
|
||||
];
|
||||
foreach ($files_to_concat as $file) {
|
||||
$cmd_parts[] = escapeshellarg($file);
|
||||
// Use babel-transformed version if it exists, otherwise use original
|
||||
$file_to_use = $this->babel_file_mapping[$file] ?? $file;
|
||||
$cmd_parts[] = escapeshellarg($file_to_use);
|
||||
}
|
||||
$cmd = implode(' ', $cmd_parts);
|
||||
|
||||
@@ -1861,6 +1875,7 @@ implode("\n", array_map(fn ($f) => ' - ' . str_replace(base_path() . '/', '',
|
||||
|
||||
if ($return_var !== 0) {
|
||||
$error_msg = implode("\n", $output);
|
||||
|
||||
throw new RuntimeException('Failed to concatenate CSS files: ' . $error_msg);
|
||||
}
|
||||
|
||||
@@ -2161,4 +2176,27 @@ JS;
|
||||
// Write to temporary file
|
||||
return $this->_write_temp_file($js_code, 'js');
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively scan directory for files with specific extension
|
||||
*/
|
||||
protected function _scan_directory_recursive(string $path, string $extension): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
if (!is_dir($path)) {
|
||||
return $files;
|
||||
}
|
||||
|
||||
$directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile() && $file->getExtension() === $extension) {
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user