-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] 入口html 支持 type="module" 的 script #260
Comments
@lijianzhang 目前,icestark 已支持 esm 子应用
<AppRouter>
<AppRoute
activePath="/seller"
entryContent={`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" crossorigin src="/index.js"></script>
<link rel="stylesheet" href="/index.css">
</head>
<body>
<div id="app"></di
</body>
</html>`}
>
</AppRoute>
</AppRouter> 在子应用中,可通过 目前针对 esm,icestark 暂不支持 |
以下是有关支持 esm 微应用的讨论。 icestark 支持 esm 微应用背景icestark 支持 umd、js 自执行打包模式,需支持 esm 规范的子应用 方案方案一:在现有方案下,若要支持 esm,可通过 entry 的方式来支持(现有,已支持)。 <AppRouter>
<AppRoute
activePath="/seller"
entryContent={`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" crossorigin src="/index.js"></script>
<link rel="stylesheet" href="/index.css">
</head>
<body>
<div id="app"></di
</body>
</html>`}
>
</AppRoute>
</AppRouter> 也可在子应用中通过 import { getMountNode } from '@ali/icestark';
const mountNode = getMountNode();
// 子应用
registerAppEnter(() => {
ReactDOM。render(App, mountNode)
})
registerAppLeave(() => {
ReactDOM.unmountComponentAtNode(mountNode)
}) 方案二:支持 新增 interface AppConfig {
...
scriptAttributes: ['type=module'],
} 使用方式: <AppRouter>
<AppRoute
name="seller",
path="/seller",
url={['https://xxx.js']}
scriptAttributes={['crossorigin=annoymous', 'type=module']}
</AppRouter /> 以上这是声明 script 为 esm。子应用支持导出 mount/unmount 生命周期。 import App from './App';
export function mount () {
...
}
export function unmount () {
...
} 其他
|
答主问题解决了吗? |
@kissy-xxy 内容被 icestark 处理过后重新挂载了 |
比如用 vite 打包出来的入口文件格式为
The text was updated successfully, but these errors were encountered: