Merge pull request 'refactor: module federation' (#32) from refactor/module-federation into main

Reviewed-on: #32
This commit was merged in pull request #32.
This commit is contained in:
2026-02-22 22:11:56 +00:00
4 changed files with 35 additions and 16 deletions

View File

@@ -9,7 +9,7 @@
"vue": "/vendor/vue.mjs",
"vue-router": "/vendor/vue-router.mjs",
"pinia": "/vendor/pinia.mjs",
"@KTXC/utils/helpers/fetch-wrapper-core": "/js/shared-utils.js"
"@KTXC": "/js/ktxc.mjs"
}
}
</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: {
public: path.resolve(__dirname, 'core/src/public.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: {
// 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,
entryFileNames: (chunkInfo) => {
// Keep shared-utils without hash for stable import map reference
if (chunkInfo.name === 'shared-utils') {
return `js/[name].js`;
// Keep ktxc without hash for stable import map references
if (chunkInfo.name === 'ktxc') {
return `js/ktxc.mjs`;
}
return `js/[name]-[hash].js`;
},