Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
47c0f439
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47c0f439
编写于
7月 26, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix path normalization for windows paths w/ non ascii chars
上级
e3b1030a
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
856 addition
and
824 deletion
+856
-824
packages/uni-app-vite/dist/plugin/build.js
packages/uni-app-vite/dist/plugin/build.js
+1
-2
packages/uni-app-vite/dist/plugins/copy.js
packages/uni-app-vite/dist/plugins/copy.js
+4
-5
packages/uni-app-vite/dist/plugins/manifestJson.js
packages/uni-app-vite/dist/plugins/manifestJson.js
+1
-1
packages/uni-app-vite/src/plugin/build.ts
packages/uni-app-vite/src/plugin/build.ts
+4
-3
packages/uni-app-vite/src/plugins/copy.ts
packages/uni-app-vite/src/plugins/copy.ts
+9
-6
packages/uni-app-vite/src/plugins/manifestJson.ts
packages/uni-app-vite/src/plugins/manifestJson.ts
+2
-1
packages/uni-app-vue/dist/service.runtime.esm.js
packages/uni-app-vue/dist/service.runtime.esm.js
+495
-507
packages/uni-cli-shared/__tests__/easycom.spec.ts
packages/uni-cli-shared/__tests__/easycom.spec.ts
+25
-9
packages/uni-cli-shared/package.json
packages/uni-cli-shared/package.json
+0
-1
packages/uni-cli-shared/src/easycom.ts
packages/uni-cli-shared/src/easycom.ts
+9
-4
packages/uni-cli-shared/src/json/pages.ts
packages/uni-cli-shared/src/json/pages.ts
+2
-3
packages/uni-cli-shared/src/utils.ts
packages/uni-cli-shared/src/utils.ts
+2
-3
packages/uni-cli-shared/src/vite/plugins/console.ts
packages/uni-cli-shared/src/vite/plugins/console.ts
+0
-3
packages/uni-cli-shared/src/vite/plugins/css.ts
packages/uni-cli-shared/src/vite/plugins/css.ts
+2
-3
packages/uni-cli-shared/src/vite/plugins/jsonJs.ts
packages/uni-cli-shared/src/vite/plugins/jsonJs.ts
+2
-2
packages/uni-cli-shared/src/vite/plugins/mainJs.ts
packages/uni-cli-shared/src/vite/plugins/mainJs.ts
+4
-2
packages/uni-h5-vite/dist/handleHotUpdate/index.js
packages/uni-h5-vite/dist/handleHotUpdate/index.js
+1
-2
packages/uni-h5-vite/dist/plugins/mainJs.js
packages/uni-h5-vite/dist/plugins/mainJs.js
+1
-2
packages/uni-h5-vite/dist/plugins/pagesJson.js
packages/uni-h5-vite/dist/plugins/pagesJson.js
+1
-2
packages/uni-h5-vite/dist/plugins/setup.js
packages/uni-h5-vite/dist/plugins/setup.js
+1
-2
packages/uni-h5-vite/src/handleHotUpdate/index.ts
packages/uni-h5-vite/src/handleHotUpdate/index.ts
+2
-2
packages/uni-h5-vite/src/plugins/mainJs.ts
packages/uni-h5-vite/src/plugins/mainJs.ts
+2
-3
packages/uni-h5-vite/src/plugins/pagesJson.ts
packages/uni-h5-vite/src/plugins/pagesJson.ts
+2
-2
packages/uni-h5-vite/src/plugins/setup.ts
packages/uni-h5-vite/src/plugins/setup.ts
+4
-3
packages/vite-plugin-uni/package.json
packages/vite-plugin-uni/package.json
+1
-2
packages/vite-plugin-uni/src/config/build.ts
packages/vite-plugin-uni/src/config/build.ts
+2
-3
packages/vite-plugin-uni/src/config/resolve.ts
packages/vite-plugin-uni/src/config/resolve.ts
+9
-1
packages/vite-plugin-uni/src/configResolved/index.ts
packages/vite-plugin-uni/src/configResolved/index.ts
+11
-1
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
+9
-4
packages/vite-plugin-uni/src/configResolved/plugins/json.ts
packages/vite-plugin-uni/src/configResolved/plugins/json.ts
+5
-3
packages/vite-plugin-uni/src/resolveId/index.ts
packages/vite-plugin-uni/src/resolveId/index.ts
+2
-2
packages/vite-plugin-uni/src/utils/filter.ts
packages/vite-plugin-uni/src/utils/filter.ts
+3
-4
yarn.lock
yarn.lock
+238
-231
未找到文件。
packages/uni-app-vite/dist/plugin/build.js
浏览文件 @
47c0f439
...
...
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
buildOptions
=
void
0
;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
slash_1
=
__importDefault
(
require
(
"
slash
"
));
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
function
buildOptions
()
{
return
{
...
...
@@ -20,7 +19,7 @@ function buildOptions() {
chunkFileNames
(
chunk
)
{
if
(
chunk
.
isDynamicEntry
&&
chunk
.
facadeModuleId
)
{
const
filepath
=
path_1
.
default
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
chunk
.
facadeModuleId
);
return
slash_1
.
default
(
filepath
.
replace
(
path_1
.
default
.
extname
(
filepath
),
'
.js
'
));
return
uni_cli_shared_1
.
normalizePath
(
filepath
.
replace
(
path_1
.
default
.
extname
(
filepath
),
'
.js
'
));
}
return
'
[name].js
'
;
},
...
...
packages/uni-app-vite/dist/plugins/copy.js
浏览文件 @
47c0f439
...
...
@@ -5,21 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
uniCopyPlugin
=
void
0
;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
slash_1
=
__importDefault
(
require
(
"
slash
"
));
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
function
uniCopyPlugin
()
{
return
uni_cli_shared_1
.
uniViteCopyPlugin
({
targets
:
[
{
src
:
slash_1
.
default
(
path_1
.
default
.
resolve
(
__dirname
,
'
../../lib/template/*.js
'
)),
src
:
uni_cli_shared_1
.
normalizePath
(
path_1
.
default
.
resolve
(
__dirname
,
'
../../lib/template/*.js
'
)),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
},
{
src
:
slash_1
.
default
(
path_1
.
default
.
resolve
(
__dirname
,
'
../../lib/template/*.png
'
)),
src
:
uni_cli_shared_1
.
normalizePath
(
path_1
.
default
.
resolve
(
__dirname
,
'
../../lib/template/*.png
'
)),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
},
{
src
:
slash_1
.
default
(
path_1
.
default
.
resolve
(
__dirname
,
'
../../lib/template/__uniappview.html
'
)),
src
:
uni_cli_shared_1
.
normalizePath
(
path_1
.
default
.
resolve
(
__dirname
,
'
../../lib/template/__uniappview.html
'
)),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
transform
(
content
)
{
const
{
globalStyle
}
=
uni_cli_shared_1
.
parsePagesJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_PLATFORM
);
...
...
@@ -36,7 +35,7 @@ function uniCopyPlugin() {
},
},
{
src
:
slash_1
.
default
(
require
.
resolve
(
'
@dcloudio/uni-app-plus/dist/uni-app-view.umd.js
'
)),
src
:
uni_cli_shared_1
.
normalizePath
(
require
.
resolve
(
'
@dcloudio/uni-app-plus/dist/uni-app-view.umd.js
'
)),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
},
],
...
...
packages/uni-app-vite/dist/plugins/manifestJson.js
浏览文件 @
47c0f439
...
...
@@ -17,7 +17,7 @@ function uniManifestJsonPlugin() {
return
;
}
this
.
addWatchFile
(
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json
'
));
manifestJson
=
uni_cli_shared_1
.
normalizeAppManifestJson
(
JSON
.
parse
(
code
),
uni_cli_shared_1
.
parsePagesJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_PLATFORM
));
manifestJson
=
uni_cli_shared_1
.
normalizeAppManifestJson
(
uni_cli_shared_1
.
parseJson
(
code
),
uni_cli_shared_1
.
parsePagesJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_PLATFORM
));
return
''
;
},
generateBundle
()
{
...
...
packages/uni-app-vite/src/plugin/build.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
UserConfig
}
from
'
vite
'
import
{
resolveMainPathOnce
}
from
'
@dcloudio/uni-cli-shared
'
import
{
normalizePath
,
resolveMainPathOnce
}
from
'
@dcloudio/uni-cli-shared
'
export
function
buildOptions
():
UserConfig
[
'
build
'
]
{
return
{
...
...
@@ -20,7 +19,9 @@ export function buildOptions(): UserConfig['build'] {
process
.
env
.
UNI_INPUT_DIR
,
chunk
.
facadeModuleId
)
return
slash
(
filepath
.
replace
(
path
.
extname
(
filepath
),
'
.js
'
))
return
normalizePath
(
filepath
.
replace
(
path
.
extname
(
filepath
),
'
.js
'
)
)
}
return
'
[name].js
'
},
...
...
packages/uni-app-vite/src/plugins/copy.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
parsePagesJsonOnce
,
uniViteCopyPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
normalizePath
,
parsePagesJsonOnce
,
uniViteCopyPlugin
,
}
from
'
@dcloudio/uni-cli-shared
'
export
function
uniCopyPlugin
()
{
return
uniViteCopyPlugin
({
targets
:
[
{
src
:
slas
h
(
path
.
resolve
(
__dirname
,
'
../../lib/template/*.js
'
)),
src
:
normalizePat
h
(
path
.
resolve
(
__dirname
,
'
../../lib/template/*.js
'
)),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
},
{
src
:
slas
h
(
path
.
resolve
(
__dirname
,
'
../../lib/template/*.png
'
)),
src
:
normalizePat
h
(
path
.
resolve
(
__dirname
,
'
../../lib/template/*.png
'
)),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
},
{
src
:
slas
h
(
src
:
normalizePat
h
(
path
.
resolve
(
__dirname
,
'
../../lib/template/__uniappview.html
'
)
),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
...
...
@@ -40,7 +43,7 @@ export function uniCopyPlugin() {
},
},
{
src
:
slas
h
(
src
:
normalizePat
h
(
require
.
resolve
(
'
@dcloudio/uni-app-plus/dist/uni-app-view.umd.js
'
)
),
dest
:
process
.
env
.
UNI_OUTPUT_DIR
,
...
...
packages/uni-app-vite/src/plugins/manifestJson.ts
浏览文件 @
47c0f439
...
...
@@ -4,6 +4,7 @@ import { Plugin } from 'vite'
import
{
defineUniManifestJsonPlugin
,
normalizeAppManifestJson
,
parseJson
,
parsePagesJsonOnce
,
}
from
'
@dcloudio/uni-cli-shared
'
...
...
@@ -21,7 +22,7 @@ export function uniManifestJsonPlugin(): Plugin {
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json
'
)
)
manifestJson
=
normalizeAppManifestJson
(
JSON
.
parse
(
code
),
parseJson
(
code
),
parsePagesJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_PLATFORM
...
...
packages/uni-app-vue/dist/service.runtime.esm.js
浏览文件 @
47c0f439
此差异已折叠。
点击以展开。
packages/uni-cli-shared/__tests__/easycom.spec.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
{
normalizePath
}
from
'
../src/utils
'
import
{
initEasycoms
,
matchEasycom
}
from
'
../src/easycom
'
const
rootDir
=
path
.
resolve
(
__dirname
,
'
examples/easycom
'
)
...
...
@@ -9,26 +9,42 @@ describe('easycom', () => {
expect
(
initEasycoms
(
rootDir
,
'
h5
'
).
easycoms
).
toEqual
([
{
pattern
:
new
RegExp
(
'
^test$
'
),
replacement
:
'
@/components/test/test.vue
'
,
replacement
:
normalizePath
(
path
.
resolve
(
rootDir
,
'
components/test/test.vue
'
)
),
},
{
pattern
:
new
RegExp
(
'
^test1$
'
),
replacement
:
'
@/components/test1/test1.vue
'
,
replacement
:
normalizePath
(
path
.
resolve
(
rootDir
,
'
components/test1/test1.vue
'
)
),
},
{
pattern
:
new
RegExp
(
'
^test2$
'
),
replacement
:
'
@/uni_modules/plugin/components/test2/test2.vue
'
,
replacement
:
normalizePath
(
path
.
resolve
(
rootDir
,
'
uni_modules/plugin/components/test2/test2.vue
'
)
),
},
{
pattern
:
new
RegExp
(
'
^uni-(.*)
'
),
replacement
:
'
@/components/uni-$1.vue
'
,
replacement
:
normalizePath
(
path
.
resolve
(
rootDir
,
'
components/uni-$1.vue
'
)
),
},
])
expect
(
matchEasycom
(
'
test
'
)).
toBe
(
'
@/components/test/test.vue
'
)
expect
(
matchEasycom
(
'
test1
'
)).
toBe
(
'
@/components/test1/test1.vue
'
)
expect
(
matchEasycom
(
'
test
'
)).
toBe
(
normalizePath
(
path
.
resolve
(
rootDir
,
'
components/test/test.vue
'
))
)
expect
(
matchEasycom
(
'
test1
'
)).
toBe
(
normalizePath
(
path
.
resolve
(
rootDir
,
'
components/test1/test1.vue
'
))
)
expect
(
matchEasycom
(
'
test2
'
)).
toBe
(
'
@/uni_modules/plugin/components/test2/test2.vue
'
normalizePath
(
path
.
resolve
(
rootDir
,
'
uni_modules/plugin/components/test2/test2.vue
'
)
)
)
expect
(
matchEasycom
(
'
uni-test1
'
)).
toBe
(
normalizePath
(
path
.
resolve
(
rootDir
,
'
components/uni-test1.vue
'
))
)
expect
(
matchEasycom
(
'
uni-test1
'
)).
toBe
(
'
@/components/uni-test1.vue
'
)
})
})
packages/uni-cli-shared/package.json
浏览文件 @
47c0f439
...
...
@@ -26,7 +26,6 @@
"jsonc-parser"
:
"^3.0.0"
,
"merge"
:
"^2.1.1"
,
"rollup-plugin-copy"
:
"^3.4.0"
,
"slash"
:
"^3.0.0"
,
"tapable"
:
"^2.2.0"
,
"xregexp"
:
"3.1.0"
},
...
...
packages/uni-cli-shared/src/easycom.ts
浏览文件 @
47c0f439
import
fs
from
'
fs
'
import
path
from
'
path
'
import
debug
from
'
debug
'
import
slash
from
'
slash
'
import
{
extend
}
from
'
@vue/shared
'
import
{
createFilter
}
from
'
@rollup/pluginutils
'
import
{
once
}
from
'
@dcloudio/uni-shared
'
import
{
normalizePath
}
from
'
./utils
'
import
{
parsePagesJson
,
parsePagesJsonOnce
}
from
'
./json/pages
'
interface
EasycomOption
{
dirs
?:
string
[]
rootDir
?
:
string
rootDir
:
string
extensions
?:
string
[]
autoscan
?:
boolean
custom
?:
EasycomCustom
...
...
@@ -118,7 +118,12 @@ function initEasycom({
extend
(
easycomsObj
,
initAutoScanEasycoms
(
dirs
,
rootDir
,
extensions
))
}
if
(
custom
)
{
extend
(
easycomsObj
,
custom
)
Object
.
keys
(
custom
).
forEach
((
name
)
=>
{
const
componentPath
=
custom
[
name
]
easycomsObj
[
name
]
=
componentPath
.
startsWith
(
'
@/
'
)
?
normalizePath
(
path
.
join
(
rootDir
!
,
componentPath
.
substr
(
2
)))
:
componentPath
})
}
Object
.
keys
(
easycomsObj
).
forEach
((
name
)
=>
{
easycoms
.
push
({
...
...
@@ -172,7 +177,7 @@ function initAutoScanEasycom(
if
(
!
isDir
(
folder
))
{
return
}
const
importDir
=
slas
h
(
folder
)
const
importDir
=
normalizePat
h
(
folder
)
const
files
=
fs
.
readdirSync
(
folder
)
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
for
(
let
i
=
0
;
i
<
extensions
.
length
;
i
++
)
{
...
...
packages/uni-cli-shared/src/json/pages.ts
浏览文件 @
47c0f439
import
fs
from
'
fs
'
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
extend
,
hasOwn
,
isArray
,
isPlainObject
}
from
'
@vue/shared
'
import
{
once
,
TABBAR_HEIGHT
}
from
'
@dcloudio/uni-shared
'
import
{
normalizePath
}
from
'
../utils
'
import
{
parseJson
}
from
'
./json
'
export
const
parsePagesJson
=
(
...
...
@@ -84,7 +83,7 @@ function normalizeSubpackages(
subpackages
.
forEach
(({
root
,
pages
:
subPages
})
=>
{
if
(
root
&&
subPages
.
length
)
{
subPages
.
forEach
((
subPage
)
=>
{
subPage
.
path
=
slas
h
(
path
.
join
(
root
,
subPage
.
path
))
subPage
.
path
=
normalizePat
h
(
path
.
join
(
root
,
subPage
.
path
))
pages
.
push
(
subPage
)
})
}
...
...
packages/uni-cli-shared/src/utils.ts
浏览文件 @
47c0f439
import
fs
from
'
fs
'
import
os
from
'
os
'
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
camelize
,
capitalize
}
from
'
@vue/shared
'
import
{
once
}
from
'
@dcloudio/uni-shared
'
import
{
PAGE_EXTNAME
,
PAGE_EXTNAME_APP
}
from
'
./constants
'
const
isWindows
=
os
.
platform
()
===
'
win32
'
export
const
isWindows
=
os
.
platform
()
===
'
win32
'
export
function
normalizePath
(
id
:
string
):
string
{
return
path
.
posix
.
normalize
(
isWindows
?
slash
(
id
)
:
id
)
return
isWindows
?
id
.
replace
(
/
\\
/g
,
'
/
'
)
:
id
}
export
const
resolveMainPathOnce
=
once
((
inputDir
:
string
)
=>
{
...
...
packages/uni-cli-shared/src/vite/plugins/console.ts
浏览文件 @
47c0f439
// import path from 'path'
// import slash from 'slash'
import
{
Plugin
}
from
'
vite
'
import
{
createFilter
,
FilterPattern
}
from
'
@rollup/pluginutils
'
...
...
packages/uni-cli-shared/src/vite/plugins/css.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
debug
from
'
debug
'
import
slash
from
'
slash
'
import
{
Plugin
}
from
'
vite
'
import
{
resolveMainPathOnce
}
from
'
../../utils
'
import
{
normalizePath
,
resolveMainPathOnce
}
from
'
../../utils
'
import
{
EXTNAME_VUE_RE
}
from
'
../../constants
'
const
cssLangs
=
`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`
...
...
@@ -20,7 +19,7 @@ const isCss = (id: string): boolean =>
cssLangRE
.
test
(
id
)
&&
!
commonjsProxyRE
.
test
(
id
)
function
normalizeCssChunkFilename
(
id
:
string
)
{
return
slas
h
(
return
normalizePat
h
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
id
.
split
(
'
?
'
)[
0
].
replace
(
EXTNAME_VUE_RE
,
'
.css
'
)
...
...
packages/uni-cli-shared/src/vite/plugins/jsonJs.ts
浏览文件 @
47c0f439
import
fs
from
'
fs
'
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
normalizePath
}
from
'
../../utils
'
import
{
CreateUniViteFilterPlugin
,
UniViteFilterPluginOptions
,
...
...
@@ -39,7 +39,7 @@ function createDefineJsonJsPlugin(name: 'pages.json' | 'manifest.json') {
}
plugin
.
configResolved
=
function
(
config
)
{
opts
.
resolvedConfig
=
config
jsonPath
=
slas
h
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
name
))
jsonPath
=
normalizePat
h
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
name
))
return
origConfigResolved
&&
origConfigResolved
(
config
)
}
...
...
packages/uni-cli-shared/src/vite/plugins/mainJs.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
normalizePath
}
from
'
../../utils
'
import
{
CreateUniViteFilterPlugin
,
...
...
@@ -23,7 +23,9 @@ export function defineUniMainJsPlugin(
let
mainTsPath
=
''
plugin
.
configResolved
=
function
(
config
)
{
opts
.
resolvedConfig
=
config
const
mainPath
=
slash
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
main
'
))
const
mainPath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
main
'
)
)
mainJsPath
=
mainPath
+
'
.js
'
mainTsPath
=
mainPath
+
'
.ts
'
return
origConfigResolved
&&
origConfigResolved
(
config
)
...
...
packages/uni-h5-vite/dist/handleHotUpdate/index.js
浏览文件 @
47c0f439
...
...
@@ -15,14 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports
.
createHandleHotUpdate
=
void
0
;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
debug_1
=
__importDefault
(
require
(
"
debug
"
));
const
slash_1
=
__importDefault
(
require
(
"
slash
"
));
const
shared_1
=
require
(
"
@vue/shared
"
);
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
utils_1
=
require
(
"
../utils
"
);
const
debugHmr
=
debug_1
.
default
(
'
vite:uni:hmr
'
);
function
invalidate
(
file
,
moduleGraph
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
mods
=
yield
moduleGraph
.
getModulesByFile
(
slash_1
.
default
(
file
));
const
mods
=
yield
moduleGraph
.
getModulesByFile
(
uni_cli_shared_1
.
normalizePath
(
file
));
if
(
mods
&&
mods
.
size
)
{
;
[...
mods
].
forEach
((
mod
)
=>
{
...
...
packages/uni-h5-vite/dist/plugins/mainJs.js
浏览文件 @
47c0f439
...
...
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
uniMainJsPlugin
=
void
0
;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
slash_1
=
__importDefault
(
require
(
"
slash
"
));
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
utils_1
=
require
(
"
../utils
"
);
function
uniMainJsPlugin
()
{
...
...
@@ -16,7 +15,7 @@ function uniMainJsPlugin() {
name
:
'
vite:uni-h5-main-js
'
,
enforce
:
'
pre
'
,
configResolved
(
config
)
{
pagesJsonJsPath
=
slash_1
.
default
(
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json.js
'
));
pagesJsonJsPath
=
uni_cli_shared_1
.
normalizePath
(
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json.js
'
));
isSSR
=
utils_1
.
isSsr
(
config
.
command
,
config
)
||
utils_1
.
isSsrManifest
(
config
.
command
,
config
);
},
...
...
packages/uni-h5-vite/dist/plugins/pagesJson.js
浏览文件 @
47c0f439
...
...
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
uniPagesJsonPlugin
=
void
0
;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
slash_1
=
__importDefault
(
require
(
"
slash
"
));
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
pkg
=
require
(
'
@dcloudio/vite-plugin-uni/package.json
'
);
function
uniPagesJsonPlugin
()
{
...
...
@@ -34,7 +33,7 @@ function generatePagesJsonCode(ssr, jsonStr, config) {
const
definePagesCode
=
generatePagesDefineCode
(
pagesJson
,
config
);
const
uniRoutesCode
=
generateRoutes
(
globalName
,
pagesJson
,
config
);
const
uniConfigCode
=
generateConfig
(
globalName
,
pagesJson
,
config
);
const
manifestJsonPath
=
slash_1
.
default
(
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json.js
'
));
const
manifestJsonPath
=
uni_cli_shared_1
.
normalizePath
(
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json.js
'
));
const
cssCode
=
generateCssCode
(
config
);
return
`
import { defineAsyncComponent, resolveComponent, createVNode, withCtx, openBlock, createBlock } from 'vue'
...
...
packages/uni-h5-vite/dist/plugins/setup.js
浏览文件 @
47c0f439
...
...
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
uniSetupPlugin
=
void
0
;
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
slash_1
=
__importDefault
(
require
(
"
slash
"
));
const
debug_1
=
__importDefault
(
require
(
"
debug
"
));
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
debugSetup
=
debug_1
.
default
(
'
vite:uni:setup
'
);
...
...
@@ -14,7 +13,7 @@ function uniSetupPlugin() {
return
{
name
:
'
vite:uni-setup
'
,
configResolved
()
{
appVuePath
=
slash_1
.
default
(
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
App.vue
'
));
appVuePath
=
uni_cli_shared_1
.
normalizePath
(
path_1
.
default
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
App.vue
'
));
},
transform
(
code
,
id
)
{
const
{
filename
,
query
}
=
uni_cli_shared_1
.
parseVueRequest
(
id
);
...
...
packages/uni-h5-vite/src/handleHotUpdate/index.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
debug
from
'
debug
'
import
slash
from
'
slash
'
import
{
ModuleGraph
,
Plugin
}
from
'
vite
'
import
{
extend
}
from
'
@vue/shared
'
import
{
initEasycomsOnce
,
normalizePath
,
parseManifestJson
,
parsePagesJson
,
}
from
'
@dcloudio/uni-cli-shared
'
...
...
@@ -14,7 +14,7 @@ import { initFeatures } from '../utils'
const
debugHmr
=
debug
(
'
vite:uni:hmr
'
)
async
function
invalidate
(
file
:
string
,
moduleGraph
:
ModuleGraph
)
{
const
mods
=
await
moduleGraph
.
getModulesByFile
(
slas
h
(
file
))
const
mods
=
await
moduleGraph
.
getModulesByFile
(
normalizePat
h
(
file
))
if
(
mods
&&
mods
.
size
)
{
;[...
mods
].
forEach
((
mod
)
=>
{
debugHmr
(
'
invalidate
'
,
mod
.
id
)
...
...
packages/uni-h5-vite/src/plugins/mainJs.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
defineUniMainJsPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
defineUniMainJsPlugin
,
normalizePath
}
from
'
@dcloudio/uni-cli-shared
'
import
{
isSsr
,
isSsrManifest
}
from
'
../utils
'
export
function
uniMainJsPlugin
()
{
...
...
@@ -11,7 +10,7 @@ export function uniMainJsPlugin() {
name
:
'
vite:uni-h5-main-js
'
,
enforce
:
'
pre
'
,
configResolved
(
config
)
{
pagesJsonJsPath
=
slas
h
(
pagesJsonJsPath
=
normalizePat
h
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json.js
'
)
)
isSSR
=
...
...
packages/uni-h5-vite/src/plugins/pagesJson.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
API_DEPS_CSS
,
...
...
@@ -11,6 +10,7 @@ import {
defineUniPagesJsonPlugin
,
normalizePagesRoute
,
normalizePagePath
,
normalizePath
,
}
from
'
@dcloudio/uni-cli-shared
'
const
pkg
=
require
(
'
@dcloudio/vite-plugin-uni/package.json
'
)
...
...
@@ -47,7 +47,7 @@ function generatePagesJsonCode(
const
definePagesCode
=
generatePagesDefineCode
(
pagesJson
,
config
)
const
uniRoutesCode
=
generateRoutes
(
globalName
,
pagesJson
,
config
)
const
uniConfigCode
=
generateConfig
(
globalName
,
pagesJson
,
config
)
const
manifestJsonPath
=
slas
h
(
const
manifestJsonPath
=
normalizePat
h
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json.js
'
)
)
const
cssCode
=
generateCssCode
(
config
)
...
...
packages/uni-h5-vite/src/plugins/setup.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
debug
from
'
debug
'
import
{
Plugin
}
from
'
vite
'
import
{
parseVueRequest
}
from
'
@dcloudio/uni-cli-shared
'
import
{
normalizePath
,
parseVueRequest
}
from
'
@dcloudio/uni-cli-shared
'
const
debugSetup
=
debug
(
'
vite:uni:setup
'
)
...
...
@@ -11,7 +10,9 @@ export function uniSetupPlugin(): Plugin {
return
{
name
:
'
vite:uni-setup
'
,
configResolved
()
{
appVuePath
=
slash
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
App.vue
'
))
appVuePath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
App.vue
'
)
)
},
transform
(
code
,
id
)
{
const
{
filename
,
query
}
=
parseVueRequest
(
id
)
...
...
packages/vite-plugin-uni/package.json
浏览文件 @
47c0f439
...
...
@@ -31,8 +31,7 @@
"jsonc-parser"
:
"^3.0.0"
,
"mime"
:
"^2.5.2"
,
"module-alias"
:
"^2.2.2"
,
"postcss-selector-parser"
:
"^6.0.4"
,
"slash"
:
"^3.0.0"
"postcss-selector-parser"
:
"^6.0.4"
},
"devDependencies"
:
{
"@types/express"
:
"^4.17.12"
,
...
...
packages/vite-plugin-uni/src/config/build.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
UserConfig
}
from
'
vite
'
import
{
initEasycomsOnce
}
from
'
@dcloudio/uni-cli-shared
'
import
{
initEasycomsOnce
,
normalizePath
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
export
function
createBuild
(
...
...
@@ -18,7 +17,7 @@ export function createBuild(
path
.
dirname
(
chunkInfo
.
facadeModuleId
)
)
if
(
dirname
)
{
return
`
${
options
.
assetsDir
}
/
${
slas
h
(
dirname
).
replace
(
return
`
${
options
.
assetsDir
}
/
${
normalizePat
h
(
dirname
).
replace
(
/
\/
/g
,
'
-
'
)}
-[name].[hash].js`
...
...
packages/vite-plugin-uni/src/config/resolve.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
{
UserConfig
}
from
'
vite
'
import
{
EXTNAME_VUE
}
from
'
@dcloudio/uni-cli-shared
'
import
{
isWindows
,
EXTNAME_VUE
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
export
function
customResolver
(
updatedId
:
string
)
{
if
(
isWindows
)
{
return
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
updatedId
)
}
return
updatedId
}
export
function
createResolve
(
options
:
VitePluginUniResolvedOptions
,
_config
:
UserConfig
...
...
@@ -17,6 +24,7 @@ export function createResolve(
replacement
(
_str
:
string
,
_
$1
:
string
,
$2
:
string
)
{
return
path
.
resolve
(
options
.
inputDir
,
$2
)
},
customResolver
,
},
],
extensions
:
[
'
.mjs
'
,
'
.js
'
,
'
.ts
'
,
'
.jsx
'
,
'
.tsx
'
,
'
.json
'
].
concat
(
...
...
packages/vite-plugin-uni/src/configResolved/index.ts
浏览文件 @
47c0f439
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
formatMsg
,
checkUpdate
}
from
'
@dcloudio/uni-cli-shared
'
import
{
formatMsg
,
checkUpdate
,
isWindows
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
initEnv
}
from
'
./env
'
import
{
initOptions
}
from
'
./options
'
import
{
initPlugins
}
from
'
./plugins
'
import
{
customResolver
}
from
'
../config/resolve
'
export
function
createConfigResolved
(
options
:
VitePluginUniResolvedOptions
)
{
return
((
config
)
=>
{
...
...
@@ -13,6 +14,15 @@ export function createConfigResolved(options: VitePluginUniResolvedOptions) {
initOptions
(
options
,
config
)
initPlugins
(
config
,
options
)
initCheckUpdate
()
if
(
isWindows
)
{
// TODO 等 https://github.com/vitejs/vite/issues/3331 修复后,可以移除下列代码
const
item
=
config
.
resolve
.
alias
.
find
((
item
)
=>
typeof
item
.
find
!==
'
string
'
?
item
.
find
.
test
(
'
@
'
)
:
false
)
if
(
item
)
{
item
.
customResolver
=
customResolver
}
}
})
as
Plugin
[
'
configResolved
'
]
}
...
...
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
Plugin
}
from
'
vite
'
import
{
PUBLIC_DIR
,
uniViteCopyPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
normalizePath
,
PUBLIC_DIR
,
uniViteCopyPlugin
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
../..
'
export
function
uniCopyPlugin
({
...
...
@@ -12,11 +15,13 @@ export function uniCopyPlugin({
return
uniViteCopyPlugin
({
targets
:
[
{
src
:
slas
h
(
path
.
resolve
(
inputDir
,
PUBLIC_DIR
)),
src
:
normalizePat
h
(
path
.
resolve
(
inputDir
,
PUBLIC_DIR
)),
dest
:
outputDir
,
},
{
src
:
slash
(
path
.
resolve
(
inputDir
,
'
uni_modules/*/
'
+
PUBLIC_DIR
)),
src
:
normalizePath
(
path
.
resolve
(
inputDir
,
'
uni_modules/*/
'
+
PUBLIC_DIR
)
),
dest
:
outputDir
,
rename
:
(
_name
,
_extension
,
fullPath
)
=>
{
return
path
.
relative
(
inputDir
,
fullPath
)
...
...
packages/vite-plugin-uni/src/configResolved/plugins/json.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
Plugin
}
from
'
vite
'
import
{
parse
}
from
'
jsonc-parser
'
import
{
normalizePath
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
../..
'
export
function
uniJsonPlugin
(
options
:
VitePluginUniResolvedOptions
):
Plugin
{
const
pagesJsonPath
=
slash
(
path
.
resolve
(
options
.
inputDir
,
'
pages.json
'
))
const
manifestJsonPath
=
slash
(
const
pagesJsonPath
=
normalizePath
(
path
.
resolve
(
options
.
inputDir
,
'
pages.json
'
)
)
const
manifestJsonPath
=
normalizePath
(
path
.
resolve
(
options
.
inputDir
,
'
manifest.json
'
)
)
return
{
...
...
packages/vite-plugin-uni/src/resolveId/index.ts
浏览文件 @
47c0f439
import
slash
from
'
slash
'
import
{
Plugin
}
from
'
vite
'
import
{
normalizePath
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
export
function
createResolveId
(
options
:
VitePluginUniResolvedOptions
):
Plugin
[
'
resolveId
'
]
{
const
inputDir
=
slas
h
(
options
.
inputDir
)
const
inputDir
=
normalizePat
h
(
options
.
inputDir
)
return
function
(
id
)
{
if
(
id
.
startsWith
(
'
@/
'
))
{
return
inputDir
+
id
.
substr
(
1
)
...
...
packages/vite-plugin-uni/src/utils/filter.ts
浏览文件 @
47c0f439
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
createFilter
}
from
'
@rollup/pluginutils
'
import
{
PUBLIC_DIR
}
from
'
@dcloudio/uni-cli-shared
'
import
{
normalizePath
,
PUBLIC_DIR
}
from
'
@dcloudio/uni-cli-shared
'
export
function
createPublicFileFilter
(
base
:
string
=
'
/
'
)
{
const
publicDir
=
slas
h
(
path
.
join
(
base
,
PUBLIC_DIR
+
'
/**/*
'
))
const
uniModulesDir
=
slas
h
(
const
publicDir
=
normalizePat
h
(
path
.
join
(
base
,
PUBLIC_DIR
+
'
/**/*
'
))
const
uniModulesDir
=
normalizePat
h
(
path
.
join
(
base
,
'
uni_modules/*/
'
+
PUBLIC_DIR
+
'
/**/*
'
)
)
return
createFilter
([
publicDir
,
uniModulesDir
])
...
...
yarn.lock
浏览文件 @
47c0f439
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录