diff --git a/babel-plugin-stub-vue-imports.cjs b/babel-plugin-stub-vue-imports.cjs new file mode 100644 index 000000000..48b9779e8 --- /dev/null +++ b/babel-plugin-stub-vue-imports.cjs @@ -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(); + } + } + } + }; +}; \ No newline at end of file diff --git a/babel-plugin-stub-vue.js b/babel-plugin-stub-vue.js deleted file mode 100644 index 91c85245d..000000000 --- a/babel-plugin-stub-vue.js +++ /dev/null @@ -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} = {};`); - } - } - } - } - }; -}; \ No newline at end of file diff --git a/playwright.i18n.config.ts b/playwright.i18n.config.ts index eede0e7ec..5f7e6ca9e 100644 --- a/playwright.i18n.config.ts +++ b/playwright.i18n.config.ts @@ -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',