提交 7acb0125 编写于 作者: fxy060608's avatar fxy060608

feat(mp-toutiao): pages.json support ext:// path (#3917)

上级 ac176eac
const fs = require('fs')
const path = require('path')
const crypto = require('crypto')
const {
isNormalPage
} = require('./util')
/**
* 1.page-loader 缓存基础的 app.json page.json project.config.json
* 2.main-loader 缓存 app.json 中的 usingComponents 节点
......@@ -49,7 +52,9 @@ function getJsonFile (name) {
function getChangedJsonFileMap (clear = true) {
const changedJsonFileMap = new Map()
for (const name of changedJsonFileSet.values()) {
changedJsonFileMap.set(name + '.json', jsonFileMap.get(name))
if (isNormalPage(name)) {
changedJsonFileMap.set(name + '.json', jsonFileMap.get(name))
}
}
clear && changedJsonFileSet.clear()
return changedJsonFileMap
......@@ -361,4 +366,4 @@ module.exports = {
getChangedJsonFileMap,
getSpecialMethods,
supportGlobalUsingComponents
}
}
......@@ -6,7 +6,8 @@ const {
removeExt,
normalizePath,
camelize,
capitalize
capitalize,
isNormalPage
} = require('./util')
const {
......@@ -113,7 +114,9 @@ function isNVuePage (page, root = '') {
function isValidPage (page, root = '') {
if (typeof page === 'string' || !page.path) { // 不合法的配置
console.warn(uniI18n.__('cliShared.pagesJsonError', { 0: 'https://uniapp.dcloud.io/collocation/pages?id=pages' }))
console.warn(uniI18n.__('cliShared.pagesJsonError', {
0: 'https://uniapp.dcloud.io/collocation/pages?id=pages'
}))
return false
}
let pagePath = page.path
......@@ -213,7 +216,10 @@ function parseEntry (pagesJson) {
const weixinConfig = manifestConfig['mp-weixin'] || {}
const independentSwitch = !!weixinConfig.independent
if (independentSwitch) {
Object.values(process.UNI_SUBPACKAGES).forEach(({ root, independent = false }) => {
Object.values(process.UNI_SUBPACKAGES).forEach(({
root,
independent = false
}) => {
if (root && independent) {
const pkgRootMainJsKey = `${root}/common/main`
// const pkgRootMainJsPath = `${process.env.UNI_INPUT_DIR}/${root}/main.js`;
......@@ -239,7 +245,9 @@ function parseEntry (pagesJson) {
// pages
pagesJson.pages.forEach(page => {
process.UNI_ENTRY[page.path] = getMainJsPath(page.path)
if (isNormalPage(page.path)) {
process.UNI_ENTRY[page.path] = getMainJsPath(page.path)
}
})
// subPackages
if (Array.isArray(pagesJson.subPackages) && pagesJson.subPackages.length) {
......@@ -404,7 +412,11 @@ function initAutoComponents () {
})
if (conflictFiles.length > 0) {
conflictFiles.forEach(files => {
console.warn(uniI18n.__('cliShared.easycomConflict', { 0: '[' + files.map((file, index) => { return file }).join(',') + ']' }))
console.warn(uniI18n.__('cliShared.easycomConflict', {
0: '[' + files.map((file, index) => {
return file
}).join(',') + ']'
}))
console.log('\n')
})
}
......@@ -519,7 +531,9 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
const BUILT_IN_COMPONENTS = ['page-meta', 'navigation-bar', 'uni-match-media']
const BUILT_IN_EASYCOMS = ['unicloud-db', 'uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial', 'ad-interactive']
const BUILT_IN_EASYCOMS = ['unicloud-db', 'uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial',
'ad-interactive'
]
function isBuiltInComponent (name) { // uni-template-compiler/lib/util.js 识别微信内置组件
return BUILT_IN_COMPONENTS.includes(name)
......@@ -551,4 +565,4 @@ module.exports = {
getGlobalUsingComponentsCode,
parseUsingAutoImportComponents,
generateGlobalUsingComponentsCode
}
}
......@@ -150,8 +150,17 @@ function pathToGlob (pathString, glob, options = {}) {
}
return path.posix.join(safeStr, glob)
}
/**
* 字节跳动小程序可以配置 ext:// 开头的插件页面模板,如 ext://microapp-trade-plugin/order-confirm
* @param pagePath
* @returns
*/
function isNormalPage (pagePath) {
return !pagePath.startsWith('ext://')
}
module.exports = {
isNormalPage,
isInHBuilderX,
isInHBuilderXAlpha,
getCLIContext,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册