Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
8e5e2215
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
GitCode(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8e5e2215
编写于
11月 19, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: add resolve
上级
04ca6594
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
114 addition
and
83 deletion
+114
-83
packages/uni-cli-shared/package.json
packages/uni-cli-shared/package.json
+1
-0
packages/uni-cli-shared/src/index.ts
packages/uni-cli-shared/src/index.ts
+1
-0
packages/uni-cli-shared/src/json/mp/jsonFile.ts
packages/uni-cli-shared/src/json/mp/jsonFile.ts
+2
-1
packages/uni-cli-shared/src/resolve.ts
packages/uni-cli-shared/src/resolve.ts
+101
-0
packages/uni-cli-shared/src/utils.ts
packages/uni-cli-shared/src/utils.ts
+6
-81
pnpm-lock.yaml
pnpm-lock.yaml
+2
-0
scripts/checkVersion.js
scripts/checkVersion.js
+1
-1
未找到文件。
packages/uni-cli-shared/package.json
浏览文件 @
8e5e2215
...
...
@@ -44,6 +44,7 @@
"postcss-import"
:
"^14.0.2"
,
"postcss-load-config"
:
"^3.1.0"
,
"postcss-selector-parser"
:
"^6.0.6"
,
"resolve"
:
"^1.20.0"
,
"rollup-plugin-copy"
:
"^3.4.0"
,
"tapable"
:
"^2.2.0"
,
"xregexp"
:
"3.1.0"
...
...
packages/uni-cli-shared/src/index.ts
浏览文件 @
8e5e2215
...
...
@@ -16,6 +16,7 @@ export * from './preprocess'
export
*
from
'
./postcss
'
export
*
from
'
./filter
'
export
*
from
'
./esbuild
'
export
*
from
'
./resolve
'
export
{
M
}
from
'
./messages
'
...
...
packages/uni-cli-shared/src/json/mp/jsonFile.ts
浏览文件 @
8e5e2215
import
{
extend
}
from
'
@vue/shared
'
import
{
ComponentJson
,
PageWindowOptions
,
UsingComponents
}
from
'
./types
'
import
{
removeExt
,
relativeFile
,
normalizeNodeModules
}
from
'
../../utils
'
import
{
removeExt
,
normalizeNodeModules
}
from
'
../../utils
'
import
{
relativeFile
}
from
'
../../resolve
'
let
appJsonCache
:
Record
<
string
,
any
>
=
{}
const
jsonFilesCache
=
new
Map
<
string
,
string
>
()
...
...
packages/uni-cli-shared/src/resolve.ts
0 → 100644
浏览文件 @
8e5e2215
import
fs
from
'
fs
'
import
path
from
'
path
'
import
debug
from
'
debug
'
import
resolve
from
'
resolve
'
import
{
once
}
from
'
@dcloudio/uni-shared
'
import
{
normalizePath
}
from
'
./utils
'
const
DEFAULT_EXTENSIONS
=
[
'
.mjs
'
,
'
.js
'
,
'
.ts
'
,
'
.jsx
'
,
'
.tsx
'
,
'
.json
'
]
function
resolveWithSymlinks
(
id
:
string
,
basedir
:
string
):
string
{
return
resolve
.
sync
(
id
,
{
basedir
,
extensions
:
DEFAULT_EXTENSIONS
,
// necessary to work with pnpm
preserveSymlinks
:
true
,
})
}
export
function
relativeFile
(
from
:
string
,
to
:
string
)
{
const
relativePath
=
normalizePath
(
path
.
relative
(
path
.
dirname
(
from
),
to
))
return
relativePath
.
startsWith
(
'
.
'
)
?
relativePath
:
'
./
'
+
relativePath
}
export
const
resolveMainPathOnce
=
once
((
inputDir
:
string
)
=>
{
const
mainTsPath
=
path
.
resolve
(
inputDir
,
'
main.ts
'
)
if
(
fs
.
existsSync
(
mainTsPath
))
{
return
normalizePath
(
mainTsPath
)
}
return
normalizePath
(
path
.
resolve
(
inputDir
,
'
main.js
'
))
})
const
ownerModules
=
[
'
@dcloudio/uni-app
'
,
'
@dcloudio/vite-plugin-uni
'
]
const
paths
:
string
[]
=
[]
function
resolveNodeModulePath
(
modulePath
:
string
)
{
const
nodeModulesPaths
:
string
[]
=
[]
const
nodeModulesPath
=
path
.
join
(
modulePath
,
'
node_modules
'
)
if
(
fs
.
existsSync
(
nodeModulesPath
))
{
nodeModulesPaths
.
push
(
nodeModulesPath
)
}
const
index
=
modulePath
.
lastIndexOf
(
'
node_modules
'
)
if
(
index
>
-
1
)
{
nodeModulesPaths
.
push
(
path
.
join
(
modulePath
.
substr
(
0
,
index
),
'
node_modules
'
)
)
}
return
nodeModulesPaths
}
function
initPaths
()
{
const
cliContext
=
process
.
env
.
UNI_CLI_CONTEXT
if
(
cliContext
)
{
const
pathSet
=
new
Set
<
string
>
()
pathSet
.
add
(
path
.
join
(
cliContext
,
'
node_modules
'
))
;[
`@dcloudio/uni-`
+
process
.
env
.
UNI_PLATFORM
,
...
ownerModules
].
forEach
(
(
ownerModule
)
=>
{
let
pkgPath
:
string
=
''
try
{
pkgPath
=
require
.
resolve
(
ownerModule
+
'
/package.json
'
,
{
paths
:
[
cliContext
],
})
}
catch
(
e
)
{}
if
(
pkgPath
)
{
resolveNodeModulePath
(
path
.
dirname
(
pkgPath
)).
forEach
(
(
nodeModulePath
)
=>
{
pathSet
.
add
(
nodeModulePath
)
}
)
}
}
)
paths
.
push
(...
pathSet
)
debug
(
'
uni-paths
'
)(
paths
)
}
}
export
function
getBuiltInPaths
()
{
if
(
!
paths
.
length
)
{
initPaths
()
}
return
paths
}
export
function
resolveBuiltIn
(
path
:
string
)
{
return
require
.
resolve
(
path
,
{
paths
:
getBuiltInPaths
()
})
}
let
componentsLibPath
:
string
=
''
export
function
resolveComponentsLibPath
()
{
if
(
!
componentsLibPath
)
{
componentsLibPath
=
path
.
join
(
resolveWithSymlinks
(
'
@dcloudio/uni-components/package.json
'
,
process
.
env
.
UNI_INPUT_DIR
),
'
../lib
'
)
}
return
componentsLibPath
}
packages/uni-cli-shared/src/utils.ts
浏览文件 @
8e5e2215
...
...
@@ -2,10 +2,8 @@ import fs from 'fs'
import
os
from
'
os
'
import
path
from
'
path
'
import
{
camelize
,
capitalize
}
from
'
@vue/shared
'
import
{
once
}
from
'
@dcloudio/uni-shared
'
export
{
default
as
hash
}
from
'
hash-sum
'
import
type
{
SFCTemplateCompileOptions
}
from
'
@vue/compiler-sfc
'
import
debug
from
'
debug
'
import
{
PAGE_EXTNAME
,
PAGE_EXTNAME_APP
}
from
'
./constants
'
import
{
...
...
@@ -14,14 +12,17 @@ import {
RootNode
,
TemplateChildNode
,
}
from
'
@vue/compiler-core
'
export
let
isRunningWithYarnPnp
:
boolean
try
{
isRunningWithYarnPnp
=
Boolean
(
require
(
'
pnpapi
'
))
}
catch
{}
export
const
isWindows
=
os
.
platform
()
===
'
win32
'
export
function
normalizePath
(
id
:
string
):
string
{
return
isWindows
?
id
.
replace
(
/
\\
/g
,
'
/
'
)
:
id
}
export
function
relativeFile
(
from
:
string
,
to
:
string
)
{
return
normalizePath
(
path
.
relative
(
path
.
dirname
(
from
),
to
))
}
export
function
checkElementNodeTag
(
node
:
RootNode
|
TemplateChildNode
|
null
|
undefined
,
tag
:
string
...
...
@@ -29,82 +30,6 @@ export function checkElementNodeTag(
return
!!
node
&&
node
.
type
===
NodeTypes
.
ELEMENT
&&
node
.
tag
===
tag
}
export
const
resolveMainPathOnce
=
once
((
inputDir
:
string
)
=>
{
const
mainTsPath
=
path
.
resolve
(
inputDir
,
'
main.ts
'
)
if
(
fs
.
existsSync
(
mainTsPath
))
{
return
normalizePath
(
mainTsPath
)
}
return
normalizePath
(
path
.
resolve
(
inputDir
,
'
main.js
'
))
})
let
componentsLibPath
:
string
=
''
export
function
resolveComponentsLibPath
()
{
if
(
!
componentsLibPath
)
{
componentsLibPath
=
path
.
resolve
(
resolveBuiltIn
(
'
@dcloudio/uni-components/package.json
'
),
'
../lib
'
)
}
return
componentsLibPath
}
const
ownerModules
=
[
'
@dcloudio/uni-app
'
,
'
@dcloudio/vite-plugin-uni
'
]
const
paths
:
string
[]
=
[]
function
resolveNodeModulePath
(
modulePath
:
string
)
{
const
nodeModulesPaths
:
string
[]
=
[]
const
nodeModulesPath
=
path
.
join
(
modulePath
,
'
node_modules
'
)
if
(
fs
.
existsSync
(
nodeModulesPath
))
{
nodeModulesPaths
.
push
(
nodeModulesPath
)
}
const
index
=
modulePath
.
lastIndexOf
(
'
node_modules
'
)
if
(
index
>
-
1
)
{
nodeModulesPaths
.
push
(
path
.
join
(
modulePath
.
substr
(
0
,
index
),
'
node_modules
'
)
)
}
return
nodeModulesPaths
}
function
initPaths
()
{
const
cliContext
=
process
.
env
.
UNI_CLI_CONTEXT
if
(
cliContext
)
{
const
pathSet
=
new
Set
<
string
>
()
pathSet
.
add
(
path
.
join
(
cliContext
,
'
node_modules
'
))
;[
`@dcloudio/uni-`
+
process
.
env
.
UNI_PLATFORM
,
...
ownerModules
].
forEach
(
(
ownerModule
)
=>
{
let
pkgPath
:
string
=
''
try
{
pkgPath
=
require
.
resolve
(
ownerModule
+
'
/package.json
'
,
{
paths
:
[
cliContext
],
})
}
catch
(
e
)
{}
if
(
pkgPath
)
{
resolveNodeModulePath
(
path
.
dirname
(
pkgPath
)).
forEach
(
(
nodeModulePath
)
=>
{
pathSet
.
add
(
nodeModulePath
)
}
)
}
}
)
paths
.
push
(...
pathSet
)
debug
(
'
uni-paths
'
)(
paths
)
}
}
export
function
getBuiltInPaths
()
{
if
(
!
paths
.
length
)
{
initPaths
()
}
return
paths
}
export
function
resolveBuiltIn
(
path
:
string
)
{
return
require
.
resolve
(
path
,
{
paths
:
getBuiltInPaths
()
})
}
export
function
normalizeIdentifier
(
str
:
string
)
{
return
capitalize
(
camelize
(
str
.
replace
(
/
\/
/g
,
'
-
'
)))
}
...
...
pnpm-lock.yaml
浏览文件 @
8e5e2215
...
...
@@ -375,6 +375,7 @@ importers:
postcss-import
:
^14.0.2
postcss-load-config
:
^3.1.0
postcss-selector-parser
:
^6.0.6
resolve
:
^1.20.0
rollup-plugin-copy
:
^3.4.0
tapable
:
^2.2.0
xregexp
:
3.1.0
...
...
@@ -405,6 +406,7 @@ importers:
postcss-import
:
14.0.2_postcss@8.3.11
postcss-load-config
:
3.1.0
postcss-selector-parser
:
6.0.6
resolve
:
1.20.0
rollup-plugin-copy
:
3.4.0
tapable
:
2.2.1
xregexp
:
3.1.0
...
...
scripts/checkVersion.js
浏览文件 @
8e5e2215
...
...
@@ -19,7 +19,7 @@ const pkgs = {
next
:
'
4.0.2
'
,
},
'
vue-i18n
'
:
{
next
:
'
9.1.
7
'
,
next
:
'
9.1.
9
'
,
},
vite
:
{
latest
:
'
2.6.14
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录