Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
14ca9314
U
uni-app
项目概览
DCloud
/
uni-app
14 天 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
14ca9314
编写于
5月 04, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(ssr): compatible with vite@4.3.x
上级
6fb591fd
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
98 addition
and
16 deletion
+98
-16
packages/playground/ssr/package.json
packages/playground/ssr/package.json
+0
-1
packages/playground/ssr/vite.config.js
packages/playground/ssr/vite.config.js
+1
-1
packages/uni-cli-shared/src/hbx/alias.ts
packages/uni-cli-shared/src/hbx/alias.ts
+3
-3
packages/uni-components/package.json
packages/uni-components/package.json
+6
-1
packages/uni-h5-vite/src/plugins/ssr.ts
packages/uni-h5-vite/src/plugins/ssr.ts
+23
-3
packages/uni-h5-vite/src/utils/ssr.ts
packages/uni-h5-vite/src/utils/ssr.ts
+39
-1
packages/uni-h5-vue/package.json
packages/uni-h5-vue/package.json
+4
-2
packages/uni-h5-vue/server-renderer/index.d.ts
packages/uni-h5-vue/server-renderer/index.d.ts
+1
-0
packages/uni-h5-vue/server-renderer/index.js
packages/uni-h5-vue/server-renderer/index.js
+1
-0
packages/uni-h5-vue/server-renderer/index.mjs
packages/uni-h5-vue/server-renderer/index.mjs
+1
-0
packages/uni-h5-vue/server-renderer/package.json
packages/uni-h5-vue/server-renderer/package.json
+5
-0
pnpm-lock.yaml
pnpm-lock.yaml
+13
-3
scripts/checkVersion.js
scripts/checkVersion.js
+1
-1
未找到文件。
packages/playground/ssr/package.json
浏览文件 @
14ca9314
...
...
@@ -10,7 +10,6 @@
},
"dependencies"
:
{
"@dcloudio/uni-app"
:
"../../uni-app"
,
"@dcloudio/uni-cloud"
:
"../../uni-cloud"
,
"@dcloudio/uni-components"
:
"../../uni-components"
,
"@dcloudio/uni-h5"
:
"../../uni-h5"
,
"vue"
:
"3.2.47"
,
...
...
packages/playground/ssr/vite.config.js
浏览文件 @
14ca9314
...
...
@@ -14,5 +14,5 @@ process.env.UNI_CLOUD_SPACES = JSON.stringify([
*/
export
default
defineConfig
({
build
:
{
minify
:
false
},
plugins
:
[
uni
({
viteLegacyOptions
:
false
})],
plugins
:
[
uni
({
viteLegacyOptions
:
false
})
,
{
name
:
'
ttt
'
,
configResolved
(
config
)
{
console
.
log
(
config
.
resolve
)}
}
],
})
packages/uni-cli-shared/src/hbx/alias.ts
浏览文件 @
14ca9314
...
...
@@ -14,7 +14,7 @@ const hbxPlugins = {
export
function
initModuleAlias
()
{
const
compilerSfcPath
=
require
.
resolve
(
'
@vue/compiler-sfc
'
)
//
const serverRendererPath = require.resolve('@vue/server-renderer')
const
serverRendererPath
=
require
.
resolve
(
'
@vue/server-renderer
'
)
moduleAlias
.
addAliases
({
'
@vue/shared
'
:
require
.
resolve
(
'
@vue/shared
'
),
'
@vue/shared/dist/shared.esm-bundler.js
'
:
require
.
resolve
(
...
...
@@ -22,9 +22,9 @@ export function initModuleAlias() {
),
'
@vue/compiler-dom
'
:
require
.
resolve
(
'
@vue/compiler-dom
'
),
'
@vue/compiler-sfc
'
:
compilerSfcPath
,
//
'@vue/server-renderer': serverRendererPath,
'
@vue/server-renderer
'
:
serverRendererPath
,
'
vue/compiler-sfc
'
:
compilerSfcPath
,
//
'vue/server-renderer': serverRendererPath,
'
vue/server-renderer
'
:
serverRendererPath
,
})
if
(
process
.
env
.
VITEST
)
{
moduleAlias
.
addAliases
({
...
...
packages/uni-components/package.json
浏览文件 @
14ca9314
...
...
@@ -17,8 +17,13 @@
"url"
:
"https://github.com/dcloudio/uni-app/issues"
},
"gitHead"
:
"33e807d66e1fe47e2ee08ad9c59247e37b8884da"
,
"dependencies"
:
{
"@dcloudio/uni-cloud"
:
"3.0.0-alpha-3080220230428001"
,
"@dcloudio/uni-h5"
:
"3.0.0-alpha-3080220230428001"
,
"@dcloudio/uni-i18n"
:
"3.0.0-alpha-3080220230428001"
},
"devDependencies"
:
{
"@dcloudio/uni-shared"
:
"3.0.0-alpha-3080220230428001"
,
"@types/quill"
:
"1.3.10"
}
}
}
\ No newline at end of file
packages/uni-h5-vite/src/plugins/ssr.ts
浏览文件 @
14ca9314
...
...
@@ -3,12 +3,16 @@ import type { Plugin, ResolvedConfig } from 'vite'
import
{
OutputChunk
}
from
'
rollup
'
import
{
isSsr
,
parseRpx2UnitOnce
}
from
'
@dcloudio/uni-cli-shared
'
import
{
isSsr
,
parseRpx2UnitOnce
,
resolveBuiltIn
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
initSsrAliasOnce
,
initSsrDefine
,
rewriteSsrVue
,
rewriteSsrResolve
,
rewriteSsrNativeTag
,
rewriteSsrRenderStyle
,
generateSsrDefineCode
,
...
...
@@ -25,10 +29,26 @@ export function uniSSRPlugin(): Plugin {
name
:
'
uni:h5-ssr
'
,
config
(
userConfig
,
env
)
{
if
(
isSsr
(
env
.
command
,
userConfig
))
{
initSsrAliasOnce
()
rewriteSsrVue
()
rewriteSsrResolve
()
rewriteSsrNativeTag
()
rewriteSsrRenderStyle
(
process
.
env
.
UNI_INPUT_DIR
)
return
{
resolve
:
{
alias
:
[
{
find
:
'
vue
'
,
replacement
:
resolveBuiltIn
(
'
@dcloudio/uni-h5-vue/dist/vue.runtime.esm.js
'
),
},
{
find
:
'
vue/server-renderer
'
,
replacement
:
resolveBuiltIn
(
'
@vue/server-renderer
'
),
},
],
},
}
}
},
configResolved
(
config
:
ResolvedConfig
)
{
...
...
packages/uni-h5-vite/src/utils/ssr.ts
浏览文件 @
14ca9314
import
path
from
'
path
'
import
fs
from
'
fs
-extra
'
import
fs
from
'
fs
'
import
{
extend
,
isArray
,
isString
,
NormalizedStyle
}
from
'
@vue/shared
'
import
{
once
,
isH5NativeTag
,
createRpx2Unit
,
Rpx2UnitOptions
,
...
...
@@ -33,6 +34,43 @@ export function isSsrManifest(
return
false
}
const
SSR_ALIAS
:
Record
<
string
,
string
>
=
{
vue
:
'
@dcloudio/uni-h5-vue
'
,
'
vue/server-renderer
'
:
'
vue/server-renderer
'
,
'
@vue/server-renderer
'
:
'
@vue/server-renderer
'
,
'
@dcloudio/uni-cloud
'
:
'
@dcloudio/uni-cloud
'
,
'
@dcloudio/uni-h5
'
:
'
@dcloudio/uni-h5
'
,
'
@dcloudio/uni-i18n
'
:
'
@dcloudio/uni-i18n
'
,
'
@dcloudio/uni-shared
'
:
'
@dcloudio/uni-shared
'
,
}
export
const
initSsrAliasOnce
=
once
(()
=>
{
// 重写 package.json 的读取
const
oldJoin
=
path
.
join
const
alias
=
Object
.
keys
(
SSR_ALIAS
).
reduce
((
alias
,
key
)
=>
{
const
newKey
=
oldJoin
(
'
node_modules
'
,
key
,
'
package.json
'
)
if
(
key
.
endsWith
(
'
vue/server-renderer
'
))
{
alias
[
newKey
]
=
path
.
join
(
path
.
dirname
(
resolveBuiltIn
(
SSR_ALIAS
[
key
])),
'
package.json
'
)
}
else
{
alias
[
newKey
]
=
resolveBuiltIn
(
SSR_ALIAS
[
key
]
+
'
/package.json
'
)
}
return
alias
},
{}
as
Record
<
string
,
string
>
)
// console.log(alias)
path
.
join
=
(...
paths
:
string
[]):
string
=>
{
let
res
=
oldJoin
.
apply
(
path
,
paths
)
if
(
res
.
endsWith
(
'
package.json
'
))
{
const
key
=
Object
.
keys
(
alias
).
find
((
key
)
=>
res
.
endsWith
(
key
))
if
(
key
)
{
res
=
alias
[
key
]
}
}
return
res
}
})
export
function
initSsrDefine
(
config
:
ResolvedConfig
)
{
return
extend
(
globalThis
,
{
__IMPORT_META_ENV_BASE_URL__
:
config
.
env
.
BASE_URL
,
...
...
packages/uni-h5-vue/package.json
浏览文件 @
14ca9314
...
...
@@ -5,7 +5,8 @@
"main"
:
"dist/vue.runtime.cjs.js"
,
"module"
:
"dist/vue.runtime.esm.js"
,
"files"
:
[
"dist"
"dist"
,
"server-renderer"
],
"sideEffects"
:
false
,
"repository"
:
{
...
...
@@ -19,6 +20,7 @@
},
"gitHead"
:
"33e807d66e1fe47e2ee08ad9c59247e37b8884da"
,
"dependencies"
:
{
"@dcloudio/uni-shared"
:
"3.0.0-alpha-3080220230428001"
"@dcloudio/uni-shared"
:
"3.0.0-alpha-3080220230428001"
,
"@vue/server-renderer"
:
"3.2.47"
}
}
packages/uni-h5-vue/server-renderer/index.d.ts
0 → 100644
浏览文件 @
14ca9314
export
*
from
'
@vue/server-renderer
'
packages/uni-h5-vue/server-renderer/index.js
0 → 100644
浏览文件 @
14ca9314
module
.
exports
=
require
(
'
@vue/server-renderer
'
)
packages/uni-h5-vue/server-renderer/index.mjs
0 → 100644
浏览文件 @
14ca9314
export
*
from
'
@vue/server-renderer
'
\ No newline at end of file
packages/uni-h5-vue/server-renderer/package.json
0 → 100644
浏览文件 @
14ca9314
{
"main"
:
"index.js"
,
"module"
:
"index.mjs"
,
"types"
:
"index.d.ts"
}
\ No newline at end of file
pnpm-lock.yaml
浏览文件 @
14ca9314
...
...
@@ -200,9 +200,6 @@ importers:
'
@dcloudio/uni-app'
:
specifier
:
../../uni-app
version
:
link:../../uni-app
'
@dcloudio/uni-cloud'
:
specifier
:
../../uni-cloud
version
:
link:../../uni-cloud
'
@dcloudio/uni-components'
:
specifier
:
../../uni-components
version
:
link:../../uni-components
...
...
@@ -705,6 +702,16 @@ importers:
version
:
3.2.11
packages/uni-components
:
dependencies
:
'
@dcloudio/uni-cloud'
:
specifier
:
3.0.0-alpha-3080220230428001
version
:
link:../uni-cloud
'
@dcloudio/uni-h5'
:
specifier
:
3.0.0-alpha-3080220230428001
version
:
link:../uni-h5
'
@dcloudio/uni-i18n'
:
specifier
:
3.0.0-alpha-3080220230428001
version
:
link:../uni-i18n
devDependencies
:
'
@dcloudio/uni-shared'
:
specifier
:
3.0.0-alpha-3080220230428001
...
...
@@ -858,6 +865,9 @@ importers:
'
@dcloudio/uni-shared'
:
specifier
:
3.0.0-alpha-3080220230428001
version
:
link:../uni-shared
'
@vue/server-renderer'
:
specifier
:
3.2.47
version
:
3.2.47(vue@3.2.47)
packages/uni-i18n
:
{}
...
...
scripts/checkVersion.js
浏览文件 @
14ca9314
...
...
@@ -25,7 +25,7 @@ const pkgs = {
next
:
'
9.1.9
'
,
},
vite
:
{
latest
:
'
4.3.
3
'
,
latest
:
'
4.3.
4
'
,
},
'
@vitejs/plugin-vue
'
:
{
latest
:
'
4.2.1
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录