| 5 | import { viteStaticCopy } from 'vite-plugin-static-copy'; |
| 6 | |
| 7 | function automatedBundlerExtrasPlugin() { |
| 8 | return { |
| 9 | name: 'automated-bundler-extras', |
| 10 | enforce: 'pre' as const, |
| 11 | transform(code: string, id: string) { |
| 12 | // Patch the generic virtual bundler context to add app-specific module registrations needed by tests |
| 13 | if (id.includes('virtual:ns-bundler-context')) { |
| 14 | const importLines = [ |
| 15 | "import * as __auto_btnCounter from '/src/ui/lifecycle/pages/button-counter.ts';", |
| 16 | "import * as __auto_myControl from '/src/ui/root-view/mymodule/MyControl.ts';", |
| 17 | "import * as __auto_testPageModule from '/src/ui/page/test-page-module.ts';", |
| 18 | "import * as __auto_testModuleCssPage from '/src/ui/page/test-module-css-page.ts';", |
| 19 | // Force profiling suite into the bundle even when CI builds strip it out. |
| 20 | "import '/src/profiling/profiling-tests.ts';", |
| 21 | ]; |
| 22 | const imports = importLines.join('\n'); |
| 23 | |
| 24 | const append = `\n;(function(){\n try {\n if (global.registerModule) {\n // Register explicit modules used by automated tests (navigateToModule, xmlns)\n global.registerModule('ui/lifecycle/pages/button-counter', function(){ return __auto_btnCounter; });\n global.registerModule('ui/root-view/mymodule/MyControl', function(){ return __auto_myControl; });\n // Folder alias to satisfy xmlns=\"ui/root-view/mymodule\":MyControl\n global.registerModule('ui/root-view/mymodule', function(){ return __auto_myControl; });\n global.registerModule('ui/page/test-page-module', function(){ return __auto_testPageModule; });\n global.registerModule('ui/page/test-module-css-page', function(){ return __auto_testModuleCssPage; });\n }\n } catch(_) {}\n})();\n`; |
| 25 | |
| 26 | return { code: `${imports}\n${code}${append}`, map: null }; |
| 27 | } |
| 28 | return null; |
| 29 | }, |
| 30 | }; |
| 31 | } |
| 32 | |
| 33 | export default defineConfig(({ mode }): UserConfig => { |
| 34 | const base = typescriptConfig({ mode }); |