Files
rspade_system/node_modules/@jqhtml/webpack-loader/dist/index.js
root d7d341f752 Update npm packages to latest versions
Fix JavaScript sourcemap paths to show full file locations
Implement --build-debug flag and complete Build UI streaming
Add xterm.js terminal UI and fix asset path routing
Add RSpade Build UI service with WebSocket support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 08:12:33 +00:00

46 lines
1.7 KiB
JavaScript

/**
* JQHTML Webpack Loader
*
* Enables importing .jqhtml files in webpack projects:
*
* import UserCard from './UserCard.jqhtml';
*
* The loader:
* 1. Uses unified compiler from @jqhtml/parser
* 2. Generates ES module code that exports components
* 3. Supports source maps for debugging
*/
import { compileTemplate } from '@jqhtml/parser';
export default function jqhtmlLoader(source) {
console.log(`[JQHTML Loader] Started processing: ${this.resourcePath}`);
const callback = this.async();
if (!callback) {
throw new Error('JQHTML loader requires async mode');
}
try {
// Use unified compiler
console.log(`[JQHTML Loader] Compiling ${this.resourcePath}...`);
const compiled = compileTemplate(source, this.resourcePath, {
format: 'esm',
sourcemap: this.sourceMap,
version: undefined // Will use package.json version automatically
});
const { code, componentName } = compiled;
console.log(`[JQHTML Loader] Compiled component: ${componentName}`);
// For webpack loader, we use the ESM format directly from compiler
const moduleCode = code;
// Return the generated code (sourcemap is inline if enabled)
console.log(`[JQHTML Loader] Finished processing ${this.resourcePath}`);
callback(null, moduleCode);
}
catch (error) {
// Enhanced error reporting with file context
if (error instanceof Error) {
error.message = `JQHTML compilation failed in ${this.resourcePath}:\n${error.message}`;
}
callback(error);
}
}
// Webpack loader interface
export const raw = false; // Process source as UTF-8 string
//# sourceMappingURL=index.js.map