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

feat(cli): auto import components

上级 37d319c1
......@@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-alpha-24720191216006"
"version": "2.0.0-alpha-24720191216032"
}
......@@ -19,7 +19,7 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function noop () {}
function noop () { }
/**
* Create a cached version of a pure function.
......
......@@ -19,7 +19,7 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function noop () {}
function noop () { }
/**
* Create a cached version of a pure function.
......@@ -751,6 +751,9 @@ const protocols = { // 需要做转换的 API 列表
},
showShareMenu: {
name: 'showSharePanel'
},
hideHomeButton: {
name: 'hideBackHome'
}
};
......
......@@ -19,7 +19,7 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function noop () {}
function noop () { }
/**
* Create a cached version of a pure function.
......
......@@ -19,7 +19,7 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function noop () {}
function noop () { }
/**
* Create a cached version of a pure function.
......
......@@ -19,7 +19,7 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function noop () {}
function noop () { }
/**
* Create a cached version of a pure function.
......
......@@ -19,7 +19,7 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function noop () {}
function noop () { }
/**
* Create a cached version of a pure function.
......
......@@ -20,6 +20,11 @@ function formatSource (source) {
if (source.indexOf('@/') === 0) { // 根目录
source = source.replace('@/', '')
} else { // node_modules
if (process.env.UNI_PLATFORM === 'mp-alipay') {
if (source.indexOf('@') === 0) {
source = source.replace('@', 'npm-scope-')
}
}
source = 'node-modules/' + source
}
return removeExt(source)
......
......@@ -79,7 +79,7 @@ module.exports = {
const res = compileTemplate(source, Object.assign(options, {
optimize: false
}))
}), compile)
options.mp.platform = platforms[options.mp.platform]
......
......@@ -267,20 +267,6 @@ if (process.env.UNI_PLATFORM === 'h5') {
moduleAlias.addAlias('vue-style-loader', '@dcloudio/vue-cli-plugin-uni/packages/h5-vue-style-loader')
}
// vue cache
if ( // 非 h5 ,非 v3,非 native
process.env.UNI_PLATFORM !== 'h5' &&
!process.env.UNI_USING_V3 &&
!process.env.UNI_USING_NATIVE
) {
moduleAlias.addAlias('./loaders/pitcher', (fromPath, request, alias) => {
if (fromPath.indexOf('vue-loader') !== -1) {
return require.resolve('@dcloudio/vue-cli-plugin-hbuilderx/packages/vue-loader/lib/loaders/pitcher')
}
return request
})
}
if (process.env.UNI_PLATFORM === 'mp-toutiao') {
// !important 始终带有一个空格
moduleAlias.addAlias(
......@@ -304,6 +290,18 @@ if (runByHBuilderX) {
}
}
}
// 组件自动导入配置
process.UNI_AUTO_COMPONENTS = []
const usingAutoImportComponents = pagesJsonObj.usingAutoImportComponents
if (usingAutoImportComponents) {
Object.keys(usingAutoImportComponents).forEach(pattern => {
process.UNI_AUTO_COMPONENTS.push({
pattern: new RegExp(pattern),
replacement: usingAutoImportComponents[pattern]
})
})
}
if (
process.env.UNI_USING_CACHE &&
......@@ -321,17 +319,6 @@ if (
require('@dcloudio/uni-cli-shared/lib/cache').restore()
}
}
// 组件自动导入配置
process.UNI_AUTO_COMPONENTS = []
const usingAutoImportComponents = pagesJsonObj.usingAutoImportComponents
if (usingAutoImportComponents) {
Object.keys(usingAutoImportComponents).forEach(pattern => {
process.UNI_AUTO_COMPONENTS.push({
pattern: new RegExp(pattern),
replacement: usingAutoImportComponents[pattern]
})
})
}
runByHBuilderX && console.log(`正在编译中...`)
......
......@@ -5,12 +5,13 @@ module.exports = function (pagesJson, manifestJson) {
} = require('../mp')(pagesJson, manifestJson, require('./project.config.json'))
if (app.content && app.content.subPackages && app.content.subPackages.length === 0) {
delete app.content.subPackages
}
project.content.qqappid = project.content.appid
project.content.qqLibVersion = project.content.libVersion
delete project.content.appid
delete project.content.libVersion
}
if (project) {
project.content.qqappid = project.content.appid
project.content.qqLibVersion = project.content.libVersion
delete project.content.appid
delete project.content.libVersion
}
return [app, project]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册