You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unable to compile federated types, Error: compile TS failed, the original command is 'npx tsc --project /Users/cheng/Development/WorkSpace/fox/fox-admin-ui/apps/admin/node_modules/.federation/tsconfig.b7d6233d2c0495b724d79c9d613a94f8.json'
Error: ENOENT: no such file or directory, open '/Users/cheng/Development/WorkSpace/fox/fox-admin-ui/apps/admin/dist/@mf-types.zip'
at Object.openSync (node:fs:573:18)
at Object.readFileSync (node:fs:452:35)
at _GenerateTypesPlugin.<anonymous> (/Users/cheng/Development/WorkSpace/fox/fox-admin-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@module-federation/dts-plugin/dist/index.js:2525:140)
at Generator.next (<anonymous>)
at fulfilled (/Users/cheng/Development/WorkSpace/fox/fox-admin-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@module-federation/dts-plugin/dist/index.js:66:24)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/cheng/Development/WorkSpace/fox/fox-admin-ui/apps/admin/dist/@mf-types.zip'
}
[ Module Federation Manifest Plugin ] Manifest Link: http://localhost:3001/mf-manifest.json
● web ━━━━━━━━━━━━━━━━━━━━━━━━━ (100%) emitting after emit ready Compiled in 7.46 m (web)
> Local: http://localhost:3001/
> Network: http://172.16.39.172:3001/
MF 配置
shell:
import{createModuleFederationConfig}from'@module-federation/modern-js';/* import { NAME as appAdminName, REMOTE_URL as appAdminUrl,} from '../admin_3001/modern.config'; */import{dependencies}from'./package.json';constsingleton={singleton: true};exportdefaultcreateModuleFederationConfig({name: 'app_shell',remotes: {app_admin: `app_admin@${process.env.ADMIN_MF_URL}/mf-manifest.json`,},shared: {'@fox-ui/shared': singleton,'@fox-ui/runtime': singleton,react: { ...singleton,requiredVersion: dependencies.react},'react-dom': { ...singleton,requiredVersion: dependencies['react-dom']},i18next: singleton,'react-i18next': singleton,dayjs: { ...singleton,requiredVersion: dependencies.dayjs},antd: { ...singleton,requiredVersion: dependencies.antd},'@ant-design/icons': {
...singleton,requiredVersion: dependencies['@ant-design/icons'],},'@ant-design/pro-components': singleton,},});
版本信息
问题详情
工程简介
我们使用 Modernjs 的 MF 2.0 加 mono-repo 实现了这套架构,工程架构如下:
现有的工程目录如下所示:
我们提供了两种打包方式:
一种是在工程的根目录下启动
"pnpm --parallel --filter @app/* run dev"
,一种是cd apps/admin
进入子应用开发。我们的 MF 依赖关系如下:
app-shell
主应用(消费者 Consumer),负责提供基础的 UI 组件和基础的路由功能。在运行时动态加载子应用。
app-admin
子应用(提供者 Provider),负责提供具体的业务功能和视图,在运行时被 shell 应用动态加载。
问题描述
我们遇到了一些前端工程化上比较棘手的问题,有两种情况:
启动:
更新 admin 应用代码之后的 Log,我只是做了个删除操作,热更新用了 7s+:
cd apps/admin
进入 admin 子应用单独启动开发modern dev
会恢复正常体验变得比较快,但事实上并没有。甚至在启动时sealing asset processing
这一步骤会花费数分钟才能正常启动。请看以第二种方式 cd 进去 apps/admin 后 run dev 的 bash 执行日志:
sealing asset processing
这个步骤执行了很久 7 分钟以后报下列错误后才正常启动:MF 配置
shell:
admin:
复现链接
暂无
复现步骤
我猜想这跟 MF Server 的模块类型下载有关,但并未深入查看源码。当然,我期望是它能跟 native RSPack 甚至 Boundless-like 的 Vite dev server 一样快。
如此的话,Modern.js 便是真的 Modern JavaScript 了。
谢谢,有时间的话,我会看一下相关源码的。
The text was updated successfully, but these errors were encountered: