Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
菜鸟程序猿_c
uni-app
提交
2e576397
U
uni-app
项目概览
菜鸟程序猿_c
/
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,发现更多精彩内容 >>
提交
2e576397
编写于
2月 11, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: rename pages.json.js, manifest.json.js (#3247)
上级
083ed683
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
33 addition
and
39 deletion
+33
-39
packages/uni-app-vite/src/plugins/mainJs.ts
packages/uni-app-vite/src/plugins/mainJs.ts
+2
-2
packages/uni-app-vite/src/plugins/pagesJson.ts
packages/uni-app-vite/src/plugins/pagesJson.ts
+3
-1
packages/uni-cli-nvue/package.json
packages/uni-cli-nvue/package.json
+1
-1
packages/uni-cli-shared/src/constants.ts
packages/uni-cli-shared/src/constants.ts
+6
-0
packages/uni-cli-shared/src/vite/plugins/jsonJs.ts
packages/uni-cli-shared/src/vite/plugins/jsonJs.ts
+5
-2
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
...ges/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
+2
-1
packages/uni-h5-vite/src/plugin/handleHotUpdate/index.ts
packages/uni-h5-vite/src/plugin/handleHotUpdate/index.ts
+4
-2
packages/uni-h5-vite/src/plugins/mainJs.ts
packages/uni-h5-vite/src/plugins/mainJs.ts
+2
-7
packages/uni-h5-vite/src/plugins/pagesJson.ts
packages/uni-h5-vite/src/plugins/pagesJson.ts
+2
-6
packages/uni-mp-vite/src/plugins/mainJs.ts
packages/uni-mp-vite/src/plugins/mainJs.ts
+2
-1
packages/uni-mp-vite/src/plugins/pagesJson.ts
packages/uni-mp-vite/src/plugins/pagesJson.ts
+2
-1
pnpm-lock.yaml
pnpm-lock.yaml
+2
-15
未找到文件。
packages/uni-app-vite/src/plugins/mainJs.ts
浏览文件 @
2e576397
import
{
defineUniMainJsPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
defineUniMainJsPlugin
,
PAGES_JSON_JS
}
from
'
@dcloudio/uni-cli-shared
'
export
function
uniMainJsPlugin
()
{
return
defineUniMainJsPlugin
((
opts
)
=>
{
...
...
@@ -11,7 +11,7 @@ export function uniMainJsPlugin() {
?
createApp
(
code
)
:
createLegacyApp
(
code
)
return
{
code
:
`import './
pages.json.js
';`
+
code
,
code
:
`import './
${
PAGES_JSON_JS
}
';`
+
code
,
map
:
this
.
getCombinedSourcemap
(),
}
}
...
...
packages/uni-app-vite/src/plugins/pagesJson.ts
浏览文件 @
2e576397
...
...
@@ -8,6 +8,7 @@ import {
normalizePagesJson
,
parseManifestJsonOnce
,
getLocaleFiles
,
MANIFEST_JSON_JS
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
initWebpackNVueEntry
}
from
'
@dcloudio/uni-cli-nvue
'
...
...
@@ -48,7 +49,8 @@ export function uniPagesJsonPlugin(): Plugin {
})
return
{
code
:
`import './manifest.json.js'\n`
+
normalizeAppPagesJson
(
pagesJson
),
`import './
${
MANIFEST_JSON_JS
}
'\n`
+
normalizeAppPagesJson
(
pagesJson
),
map
:
this
.
getCombinedSourcemap
(),
}
},
...
...
packages/uni-cli-nvue/package.json
浏览文件 @
2e576397
...
...
@@ -37,7 +37,7 @@
"indexes-of"
:
"^1.0.1"
,
"less-loader"
:
"^10.0.1"
,
"loader-utils"
:
"^1.1.0"
,
"lru-cache"
:
"^
5.1.1
"
,
"lru-cache"
:
"^
4.1.2
"
,
"merge-source-map"
:
"^1.1.0"
,
"module-alias"
:
"^2.2.2"
,
"postcss"
:
"^8.4.6"
,
...
...
packages/uni-cli-shared/src/constants.ts
浏览文件 @
2e576397
...
...
@@ -16,6 +16,12 @@ export const extensions = [
'
.json
'
,
].
concat
(
EXTNAME_VUE
)
export
const
PAGES_JSON_JS
=
'
pages-json-js
'
export
const
MANIFEST_JSON_JS
=
'
manifest-json-js
'
export
const
JSON_JS_MAP
=
{
'
pages.json
'
:
PAGES_JSON_JS
,
'
manifest.json
'
:
MANIFEST_JSON_JS
,
}
as
const
export
const
ASSETS_INLINE_LIMIT
=
40
*
1024
export
const
APP_SERVICE_FILENAME
=
'
app-service.js
'
...
...
packages/uni-cli-shared/src/vite/plugins/jsonJs.ts
浏览文件 @
2e576397
import
fs
from
'
fs
'
import
path
from
'
path
'
import
{
JSON_JS_MAP
}
from
'
../../constants
'
import
{
normalizePath
}
from
'
../../utils
'
import
{
CreateUniViteFilterPlugin
,
...
...
@@ -11,7 +12,7 @@ export const defineUniManifestJsonPlugin =
createDefineJsonJsPlugin
(
'
manifest.json
'
)
function
createDefineJsonJsPlugin
(
name
:
'
pages.json
'
|
'
manifest.json
'
)
{
const
JSON_JS
=
name
+
'
.js
'
const
JSON_JS
=
JSON_JS_MAP
[
name
]
return
function
(
createVitePlugin
:
CreateUniViteFilterPlugin
)
{
const
opts
=
{
resolvedConfig
:
{},
...
...
@@ -26,6 +27,7 @@ function createDefineJsonJsPlugin(name: 'pages.json' | 'manifest.json') {
const
origConfigResolved
=
plugin
.
configResolved
let
jsonPath
=
''
let
jsonJsPath
=
''
plugin
.
resolveId
=
function
(
id
,
importer
,
options
)
{
const
res
=
...
...
@@ -34,12 +36,13 @@ function createDefineJsonJsPlugin(name: 'pages.json' | 'manifest.json') {
return
res
}
if
(
id
.
endsWith
(
JSON_JS
))
{
return
json
Path
+
'
.js
'
return
json
JsPath
}
}
plugin
.
configResolved
=
function
(
config
)
{
opts
.
resolvedConfig
=
config
jsonPath
=
normalizePath
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
name
))
jsonJsPath
=
normalizePath
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
JSON_JS
))
return
origConfigResolved
&&
origConfigResolved
(
config
)
}
...
...
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
浏览文件 @
2e576397
...
...
@@ -29,6 +29,7 @@ import type Less from 'less'
import
type
{
Alias
}
from
'
types/alias
'
import
{
transform
,
formatMessages
}
from
'
esbuild
'
import
{
preCss
,
preNVueCss
}
from
'
../../../../preprocess
'
import
{
PAGES_JSON_JS
}
from
'
../../../../constants
'
// const debug = createDebugger('vite:css')
export
interface
CSSOptions
{
...
...
@@ -196,7 +197,7 @@ function findCssModuleIds(
const
moduleInfo
=
this
.
getModuleInfo
(
moduleId
)
if
(
moduleInfo
)
{
moduleInfo
.
importedIds
.
forEach
((
id
)
=>
{
if
(
id
.
includes
(
'
pages.json.js
'
))
{
if
(
id
.
includes
(
PAGES_JSON_JS
))
{
// 查询main.js时,需要忽略pages.json.js,否则会把所有页面样式加进来
return
}
...
...
packages/uni-h5-vite/src/plugin/handleHotUpdate/index.ts
浏览文件 @
2e576397
...
...
@@ -5,7 +5,9 @@ import { extend } from '@vue/shared'
import
{
initEasycomsOnce
,
initFeatures
,
MANIFEST_JSON_JS
,
normalizePath
,
PAGES_JSON_JS
,
parseManifestJson
,
parsePagesJson
,
resolveComponentsLibPath
,
...
...
@@ -29,8 +31,8 @@ export function createHandleHotUpdate(): Plugin['handleHotUpdate'] {
const
platform
=
process
.
env
.
UNI_PLATFORM
if
(
!
invalidateFiles
)
{
invalidateFiles
=
[
path
.
resolve
(
inputDir
,
'
pages.json.js
'
),
path
.
resolve
(
inputDir
,
'
manifest.json.js
'
),
path
.
resolve
(
inputDir
,
PAGES_JSON_JS
),
path
.
resolve
(
inputDir
,
MANIFEST_JSON_JS
),
require
.
resolve
(
'
@dcloudio/uni-h5/dist/uni-h5.es.js
'
),
]
try
{
...
...
packages/uni-h5-vite/src/plugins/mainJs.ts
浏览文件 @
2e576397
import
path
from
'
path
'
import
{
defineUniMainJsPlugin
,
isSsr
,
normalizePath
,
PAGES_JSON_JS
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
isSSR
,
isSsrManifest
}
from
'
../utils
'
export
function
uniMainJsPlugin
()
{
return
defineUniMainJsPlugin
((
opts
)
=>
{
let
pagesJsonJsPath
=
''
let
runSSR
=
false
return
{
name
:
'
uni:h5-main-js
'
,
enforce
:
'
pre
'
,
configResolved
(
config
)
{
pagesJsonJsPath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json.js
'
)
)
runSSR
=
isSsr
(
config
.
command
,
config
)
||
isSsrManifest
(
config
.
command
,
config
)
},
...
...
@@ -31,7 +26,7 @@ export function uniMainJsPlugin() {
?
createSSRServerApp
(
code
)
:
createSSRClientApp
(
code
)
}
code
=
`import '
${
pagesJsonJsPath
}
';
${
code
}
`
code
=
`import '
./
${
PAGES_JSON_JS
}
';
${
code
}
`
return
{
code
,
map
:
this
.
getCombinedSourcemap
(),
...
...
packages/uni-h5-vite/src/plugins/pagesJson.ts
浏览文件 @
2e576397
import
path
from
'
path
'
import
type
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
API_DEPS_CSS
,
...
...
@@ -10,9 +9,9 @@ import {
defineUniPagesJsonPlugin
,
normalizePagesRoute
,
normalizePagePath
,
normalizePath
,
isEnableTreeShaking
,
parseManifestJsonOnce
,
MANIFEST_JSON_JS
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
isSSR
}
from
'
../utils
'
...
...
@@ -49,15 +48,12 @@ function generatePagesJsonCode(
const
definePagesCode
=
generatePagesDefineCode
(
pagesJson
,
config
)
const
uniRoutesCode
=
generateRoutes
(
globalName
,
pagesJson
,
config
)
const
uniConfigCode
=
generateConfig
(
globalName
,
pagesJson
,
config
)
const
manifestJsonPath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json.js
'
)
)
const
cssCode
=
generateCssCode
(
config
)
return
`
import { defineAsyncComponent, resolveComponent, createVNode, withCtx, openBlock, createBlock } from 'vue'
import { PageComponent, AsyncLoadingComponent, AsyncErrorComponent, useI18n, setupWindow, setupPage } from '@dcloudio/uni-h5'
import { appid, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, googleMapKey, nvue, locale, fallbackLocale } from '
${
manifestJsonPath
}
'
import { appid, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, googleMapKey, nvue, locale, fallbackLocale } from '
./
${
MANIFEST_JSON_JS
}
'
const locales = import.meta.globEager('./locale/*.json')
${
importLayoutComponentsCode
}
const extend = Object.assign
...
...
packages/uni-mp-vite/src/plugins/mainJs.ts
浏览文件 @
2e576397
import
{
defineUniMainJsPlugin
,
PAGES_JSON_JS
,
parseProgram
,
transformDynamicImports
,
updateMiniProgramGlobalComponents
,
...
...
@@ -39,7 +40,7 @@ export function uniMainJsPlugin(
})
return
{
code
:
`import 'plugin-vue:export-helper';import 'uni-mp-runtime';import './
pages.json.js
';`
+
`import 'plugin-vue:export-helper';import 'uni-mp-runtime';import './
${
PAGES_JSON_JS
}
';`
+
code
,
map
,
}
...
...
packages/uni-mp-vite/src/plugins/pagesJson.ts
浏览文件 @
2e576397
...
...
@@ -13,6 +13,7 @@ import {
addMiniProgramAppJson
,
findChangedJsonFiles
,
mergeMiniProgramAppJson
,
MANIFEST_JSON_JS
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
virtualPagePath
}
from
'
./entry
'
import
{
UniMiniProgramPluginOptions
}
from
'
../plugin
'
...
...
@@ -73,7 +74,7 @@ export function uniPagesJsonPlugin(
addMiniProgramPageJson
(
name
,
pageJsons
[
name
])
})
return
{
code
:
`import './
manifest.json.js
'\n`
+
importPagesCode
(
appJson
),
code
:
`import './
${
MANIFEST_JSON_JS
}
'\n`
+
importPagesCode
(
appJson
),
map
:
{
mappings
:
''
},
}
},
...
...
pnpm-lock.yaml
浏览文件 @
2e576397
...
...
@@ -286,7 +286,7 @@ importers:
indexes-of
:
^1.0.1
less-loader
:
^10.0.1
loader-utils
:
^1.1.0
lru-cache
:
^
5.1.1
lru-cache
:
^
4.1.2
merge-source-map
:
^1.1.0
module-alias
:
^2.2.2
postcss
:
^8.4.6
...
...
@@ -325,7 +325,7 @@ importers:
indexes-of
:
1.0.1
less-loader
:
10.2.0_webpack@5.64.4
loader-utils
:
1.4.0
lru-cache
:
5.1.1
lru-cache
:
4.1.5
merge-source-map
:
1.1.0
module-alias
:
2.2.2
postcss
:
8.4.6
...
...
@@ -7308,13 +7308,6 @@ packages:
dependencies
:
pseudomap
:
1.0.2
yallist
:
2.1.2
dev
:
true
/lru-cache/5.1.1
:
resolution
:
{
integrity
:
sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==
}
dependencies
:
yallist
:
3.1.1
dev
:
false
/lru-cache/6.0.0
:
resolution
:
{
integrity
:
sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
}
...
...
@@ -8034,7 +8027,6 @@ packages:
/pseudomap/1.0.2
:
resolution
:
{
integrity
:
sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
}
dev
:
true
/psl/1.8.0
:
resolution
:
{
integrity
:
sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==
}
...
...
@@ -9554,11 +9546,6 @@ packages:
/yallist/2.1.2
:
resolution
:
{
integrity
:
sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=
}
dev
:
true
/yallist/3.1.1
:
resolution
:
{
integrity
:
sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==
}
dev
:
false
/yallist/4.0.0
:
resolution
:
{
integrity
:
sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录