提交 79caaa9c 编写于 作者: Q qiang

chore: lint

上级 c25fc1ca
......@@ -35,7 +35,7 @@ module.exports = {
if (scriptName !== name) {
const define = uniAppOptions.scripts[scriptName].define
Object.keys(define).forEach(name => {
if (typeof scriptOptions.define[name] !== "undefined") {
if (typeof scriptOptions.define[name] !== 'undefined') {
delete define[name]
} else {
define[name] = false
......
......@@ -56,33 +56,38 @@ describe('mp:compiler-mp-weixin', () => {
it('generate string express with escape quote', () => {
assertCodegen(
`<view :data-text="text+'\\''"></view>`,
'<view :data-text="text+\'\\\'\'"></view>',
'<view data-text="{{$root.a0}}"></view>',
`with(this){var a0=text+"'";$mp.data=Object.assign({},{$root:{a0:a0}})}`
'with(this){var a0=text+"\'";$mp.data=Object.assign({},{$root:{a0:a0}})}'
)
assertCodegen(
/* eslint-disable no-template-curly-in-string */
'<view :data-text="`${text}\'`"></view>',
'<view data-text="{{$root.a0}}"></view>',
/* eslint-disable no-template-curly-in-string */
'with(this){var a0=`${text}\'`;$mp.data=Object.assign({},{$root:{a0:a0}})}'
)
assertCodegen(
`<view>{{text+'\\''}}</view>`,
'<view>{{text+\'\\\'\'}}</view>',
'<view>{{$root.t0}}</view>',
`with(this){var t0=text+"'";$mp.data=Object.assign({},{$root:{t0:t0}})}`
'with(this){var t0=text+"\'";$mp.data=Object.assign({},{$root:{t0:t0}})}'
)
assertCodegen(
/* eslint-disable no-template-curly-in-string */
'<view>{{`${text}\'`}}</view>',
'<view>{{$root.t0}}</view>',
/* eslint-disable no-template-curly-in-string */
'with(this){var t0=`${text}\'`;$mp.data=Object.assign({},{$root:{t0:t0}})}'
)
assertCodegen(
/* eslint-disable no-template-curly-in-string */
'<view>{{`${text}"`}}</view>',
`<view>{{text+'"'}}</view>`
'<view>{{text+\'"\'}}</view>'
)
assertCodegen(
`<view>{{text+"\\""}}</view>`,
'<view>{{text+"\\""}}</view>',
'<view>{{$root.t0}}</view>',
`with(this){var t0=text+"\\"";$mp.data=Object.assign({},{$root:{t0:t0}})}`
'with(this){var t0=text+"\\"";$mp.data=Object.assign({},{$root:{t0:t0}})}'
)
})
......
......@@ -248,7 +248,7 @@ function analysisPluginDir () {
process.env.UNI_MP_PLUGIN_MAIN = pluginJson.main
const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN
const mainFilePath = path.resolve(process.env.UNI_INPUT_DIR, UNI_MP_PLUGIN_MAIN)
if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) {
console.log()
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', {
......
......@@ -77,21 +77,21 @@ function addMPPluginRequire (compilation) {
if (needProcess) {
const modules = compilation.modules
const orignalSource = compilation.assets[name].source()
const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx';
const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx'
const filePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, name))
const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === filePath).id
const newlineIndex = orignalSource.lastIndexOf('\n')
const source =
orignalSource.substring(0, newlineIndex)
+ `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n`
+ orignalSource.substring(newlineIndex + 1)
orignalSource.substring(0, newlineIndex) +
`\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` +
orignalSource.substring(newlineIndex + 1)
compilation.assets[name] = {
size() {
size () {
return Buffer.byteLength(source, 'utf8')
},
source() {
source () {
return source
}
}
......
......@@ -545,7 +545,7 @@ export default {
}
},
_report (type, currentChannel) {
let reportData = {
const reportData = {
h: __uniConfig.compilerVersion,
a: this.adpid,
at: type
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册