refactor: module federation
All checks were successful
JS Unit Tests / test (pull_request) Successful in 16s
Build Test / build (pull_request) Successful in 20s
PHP Unit Tests / test (pull_request) Successful in 54s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-22 12:35:56 -05:00
parent 8560aef5e2
commit bb05f3d20f
4 changed files with 35 additions and 16 deletions

View File

@@ -9,7 +9,7 @@
"vue": "/vendor/vue.mjs", "vue": "/vendor/vue.mjs",
"vue-router": "/vendor/vue-router.mjs", "vue-router": "/vendor/vue-router.mjs",
"pinia": "/vendor/pinia.mjs", "pinia": "/vendor/pinia.mjs",
"@KTXC/utils/helpers/fetch-wrapper-core": "/js/shared-utils.js" "@KTXC": "/js/ktxc.mjs"
} }
} }
</script> </script>

28
core/src/shared/index.ts Normal file
View File

@@ -0,0 +1,28 @@
/**
* KTXC Host SDK
*
* This is the single public contract between the host application and modules.
* Modules must import from '@KTXC' (this file), never from '@KTXC/...' sub-paths.
* At runtime, '@KTXC' resolves to '/js/ktxc.mjs' via the import map.
*/
// Stores
export { useModuleStore } from '../stores/moduleStore'
export { useTenantStore } from '../stores/tenantStore'
export { useUserStore } from '../stores/userStore'
export { useIntegrationStore } from '../stores/integrationStore'
export { useLayoutStore } from '../stores/layoutStore'
// Composables
export { useUser } from '../composables/useUser'
export { useClipboard } from '../composables/useClipboard'
// Services
export { userService } from '../services/user/userService'
// Utilities
export { fetchWrapper } from '../utils/helpers/fetch-wrapper'
export { createFetchWrapper } from '../utils/helpers/fetch-wrapper-core'
// Types
export type { ModuleIntegrations } from '../types/moduleTypes'

View File

@@ -1,10 +0,0 @@
/**
* Shared utilities entry point for external modules
* This file is built separately and exposed via import map
*/
export {
createFetchWrapper,
type FetchWrapperOptions,
type RequestCallOptions,
} from './fetch-wrapper-core';

View File

@@ -72,15 +72,16 @@ export default defineConfig(({ mode }) => ({
input: { input: {
public: path.resolve(__dirname, 'core/src/public.html'), public: path.resolve(__dirname, 'core/src/public.html'),
private: path.resolve(__dirname, 'core/src/private.html'), private: path.resolve(__dirname, 'core/src/private.html'),
'shared-utils': path.resolve(__dirname, 'core/src/utils/helpers/shared.ts'), 'ktxc': path.resolve(__dirname, 'core/src/shared/index.ts'),
}, },
preserveEntrySignatures: 'exports-only',
output: { output: {
// Preserve export names for shared-utils (used via import map by modules) // Preserve export names for ktxc (used via import map by modules)
minifyInternalExports: false, minifyInternalExports: false,
entryFileNames: (chunkInfo) => { entryFileNames: (chunkInfo) => {
// Keep shared-utils without hash for stable import map reference // Keep ktxc without hash for stable import map references
if (chunkInfo.name === 'shared-utils') { if (chunkInfo.name === 'ktxc') {
return `js/[name].js`; return `js/ktxc.mjs`;
} }
return `js/[name]-[hash].js`; return `js/[name]-[hash].js`;
}, },