mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-11 08:00:21 +00:00
- Created configurable babel-plugin-inject-globals to inject browser setup - Added setup-browser-globals.mjs for browser environment mocking - Moved babel plugin files to scripts directory for better organization - Removed dependency on import order by using babel transformation - Made plugin options configurable (filenamePattern, setupFile) - Updated tsconfig.json to include playwright config and scripts This fixes the ReferenceError: location is not defined issue that occurred when running pnpm collect-i18n, ensuring the command works reliably regardless of import auto-sorting. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
32 lines
967 B
JavaScript
32 lines
967 B
JavaScript
module.exports = function(babel) {
|
|
const { types: t } = babel;
|
|
|
|
return {
|
|
visitor: {
|
|
ImportDeclaration(path) {
|
|
const source = path.node.source.value;
|
|
|
|
// Handle Vue files
|
|
if (source.endsWith('.vue')) {
|
|
const specifiers = path.node.specifiers;
|
|
if (specifiers.length > 0 && specifiers[0].type === 'ImportDefaultSpecifier') {
|
|
const name = specifiers[0].local.name;
|
|
// Replace with a variable declaration
|
|
path.replaceWith(
|
|
t.variableDeclaration('const', [
|
|
t.variableDeclarator(
|
|
t.identifier(name),
|
|
t.objectExpression([])
|
|
)
|
|
])
|
|
);
|
|
}
|
|
}
|
|
// Handle CSS files - just remove the import
|
|
else if (source.endsWith('.css') || source.endsWith('.scss') || source.endsWith('.less')) {
|
|
path.remove();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}; |