vite-plugin-federation
vite-plugin-federation copied to clipboard
vite 2.9.9 报错
Versions
- originjs: 1.1.6
- node: 12
- vite:2.9.9
vite build
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2019", "firefox78", "safari13.1")
1 | import {importShared} from './__federation_fn_import.js'
2 | const {r:react} = await importShared('react')
| ^
3 |
4 | var jsxRuntime = {exports: {}};
vite dev
Failed to resolve import "host/App" from "src\App.tsx". Does the file exist?
上午11:54:24 [vite] Internal server error: Failed to resolve import "host/App" from "src\App.tsx". Does the file exist?
Plugin: vite:import-analysis
File: D:/Develop/vite-module-federation/projects/app/src/App.tsx
remote 在 dev环境下 不生成 remotejs 入口
如果使用的是ESM格式的话,会使用top-level await
特性,必须设置target:'esnext'
export default defineConfig({
build: {
target: 'esnext',
}
})
dev模式有一些限制条件,只有完全的host端(不能包含任何expose)才可以使用dev模式,这是因为vite在dev模式下不允许添加chunk,自然也无法生成remoteEntry
如果使用的框架是react,我不建议使用dev模式,因为react的打包格式一直是cjs,调整dev(esbuild)和build(rollup)打包cjs库行为一致不是一件容易的事情,当然如果react升级为ESM的库,这个问题就不存在了
目前比较大问题 卡在
[vite] Internal server error: Failed to resolve import "host/App" from "src\App.tsx". Does the file exist?
Plugin: vite:import-analysis
目前比较大问题 卡在
[vite] Internal server error: Failed to resolve import "host/App" from "src\App.tsx". Does the file exist? Plugin: vite:import-analysis
我用dev没有报错,而且react还是尽量用build吧,dev运行起来会有其他奇奇怪怪的打包问题
https://github.com/ckken/vite-module-federation 根据约定更新了一轮
会不会跟ts 有关
你看看这个 https://github.com/originjs/vite-plugin-federation/issues/129#issuecomment-1048474627
有加的
Same error the plugin is just not working no matter what I am doing
Since vite has now been upgraded to version 4.0, I'll close this issue.