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

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-02-22 21:50:54 +00:00
4 changed files with 48 additions and 11 deletions

View File

@@ -1,7 +1,3 @@
import { useNodesStore } from '@/stores/nodesStore'
import { useProvidersStore } from '@/stores/providersStore'
import { useServicesStore } from '@/stores/servicesStore'
/**
* File Manager Module Boot Script
*
@@ -13,5 +9,10 @@ console.log('[FileManager] Booting File Manager module...')
console.log('[FileManager] File Manager module booted successfully')
// Export stores for external use if needed
export { useNodesStore, useProvidersStore, useServicesStore }
// CSS will be injected by build process
//export const css = ['__CSS_FILENAME_PLACEHOLDER__']
// Export services, stores and models for external use
export * from '@/services'
export * from '@/stores'
export * from '@/models'

View File

@@ -3,7 +3,7 @@
* Central service for making API calls to the file manager backend
*/
import { createFetchWrapper } from '@KTXC/utils/helpers/fetch-wrapper-core';
import { createFetchWrapper } from '@KTXC';
const fetchWrapper = createFetchWrapper();

3
src/stores/index.ts Normal file
View File

@@ -0,0 +1,3 @@
export { useProvidersStore } from './providersStore';
export { useServicesStore } from './servicesStore';
export { useNodesStore, ROOT_ID } from './nodesStore';

View File

@@ -1,16 +1,38 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
{
name: 'inject-css-filename',
enforce: 'post',
generateBundle(_options, bundle) {
const cssFile = Object.keys(bundle).find(name => name.endsWith('.css'))
if (!cssFile) return
for (const fileName of Object.keys(bundle)) {
const chunk = bundle[fileName]
if (chunk.type === 'chunk' && chunk.code.includes('__CSS_FILENAME_PLACEHOLDER__')) {
chunk.code = chunk.code.replace(/__CSS_FILENAME_PLACEHOLDER__/g, `static/${cssFile}`)
console.log(`Injected CSS filename "static/${cssFile}" into ${fileName}`)
}
}
}
}
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@KTXC': path.resolve(__dirname, '../../core/src')
'@KTXC': path.resolve(__dirname, '../../core/src'),
'@FilesManager': path.resolve(__dirname, './src')
},
},
build: {
outDir: 'static',
emptyOutDir: true,
sourcemap: true,
lib: {
entry: path.resolve(__dirname, 'src/main.ts'),
@@ -19,12 +41,23 @@ export default defineConfig({
},
rollupOptions: {
external: [
'pinia',
'vue',
'vue-router',
// Externalize shared utilities from core to avoid duplication
/^@KTXC\/utils\//,
'pinia',
'@KTXC',
],
output: {
paths: (id) => {
if (id === '@KTXC') return '/js/ktxc.mjs'
return id
},
assetFileNames: (assetInfo) => {
if (assetInfo.name?.endsWith('.css')) {
return 'file_manager-[hash].css'
}
return '[name]-[hash][extname]'
}
}
},
},
})