mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 23:50:08 +00:00
fix: Convert babel plugin to CommonJS format for Playwright compatibility
- Renamed babel-plugin-stub-vue-imports.js to .cjs extension - Changed from ES module exports to CommonJS module.exports - Updated playwright.i18n.config.ts to use correct file path with __dirname - Added import.meta.url handling for ES module compatibility This fixes the module resolution errors when running pnpm collect-i18n
This commit is contained in:
32
babel-plugin-stub-vue-imports.cjs
Normal file
32
babel-plugin-stub-vue-imports.cjs
Normal file
@@ -0,0 +1,32 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
module.exports = function() {
|
||||
return {
|
||||
visitor: {
|
||||
ImportDeclaration(path) {
|
||||
const source = path.node.source.value;
|
||||
if (source.endsWith('.vue')) {
|
||||
// Replace Vue component imports with a stub
|
||||
const specifiers = path.node.specifiers;
|
||||
if (specifiers.length > 0) {
|
||||
const name = specifiers[0].local.name;
|
||||
// Create a simple stub object
|
||||
path.replaceWithSourceString(`const ${name} = {};`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,8 @@
|
||||
import { defineConfig } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const config: any = defineConfig({
|
||||
testDir: './scripts',
|
||||
@@ -22,7 +26,7 @@ const config: any = defineConfig({
|
||||
config['@playwright/test'] = {
|
||||
babelPlugins: [
|
||||
// Stub Vue and CSS imports first to prevent parsing errors
|
||||
['babel-plugin-stub-vue-imports'],
|
||||
[path.join(__dirname, 'babel-plugin-stub-vue-imports.cjs')],
|
||||
// Module resolver to handle @ alias
|
||||
[
|
||||
'babel-plugin-module-resolver',
|
||||
|
||||
Reference in New Issue
Block a user