diff --git a/packages/core/src/index.js b/packages/core/src/index.js index e4e2677cc7..1ee8bcef3b 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -138,6 +138,7 @@ Mpx.config = { ignoreProxyWhiteList: ['id', 'dataset', 'data'], observeClassInstance: false, errorHandler: null, + warnHandler: null, proxyEventHandler: null, setDataHandler: null, forceFlushSync: false, diff --git a/packages/utils/src/log.js b/packages/utils/src/log.js index f0e174a86d..eba7143ff3 100644 --- a/packages/utils/src/log.js +++ b/packages/utils/src/log.js @@ -14,7 +14,13 @@ export function warn (msg, location, e) { } else if (condition instanceof RegExp) { ignore = condition.test(msg) } - if (!ignore) return log('warn', msg, location, e) + if (!ignore) { + const warnHandler = global.__mpx?.config.warnHandler + if (isFunction(warnHandler)) { + warnHandler(msg, location, e) + } + return log('warn', msg, location, e) + } } export function error (msg, location, e) { diff --git a/packages/webpack-plugin/lib/index.js b/packages/webpack-plugin/lib/index.js index 2c09e14c13..0ff066af65 100644 --- a/packages/webpack-plugin/lib/index.js +++ b/packages/webpack-plugin/lib/index.js @@ -1812,7 +1812,6 @@ try { } if (isWeb(mpx.mode)) { - const mpxStyleOptions = queryObj.mpxStyleOptions const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : '' const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher') let cssLoaderIndex = -1 @@ -1837,8 +1836,7 @@ try { } if (loaderIndex > -1) { loaders.splice(loaderIndex + 1, 0, { - loader: styleCompilerPath, - options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {} + loader: styleCompilerPath }) } } diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx index 4018c39b9d..9a53628cce 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-view.tsx @@ -383,7 +383,7 @@ function wrapImage (imageStyle?: ExtendedViewStyle) { } } - return + return {show && } } diff --git a/packages/webpack-plugin/lib/runtime/components/react/utils.tsx b/packages/webpack-plugin/lib/runtime/components/react/utils.tsx index dda6623705..5c056bf1e9 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/utils.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/utils.tsx @@ -256,19 +256,6 @@ function transformCalc (styleObj: Record, calcKeyPaths: Array) { - let { lineHeight } = styleObj - if (typeof lineHeight === 'string' && PERCENT_REGEX.test(lineHeight)) { - const hasFontSize = hasOwn(styleObj, 'fontSize') - if (!hasFontSize) { - warn('The fontSize property could not be read correctly, so the default fontSize of 16 will be used as the basis for calculating the lineHeight!') - } - const fontSize = hasFontSize ? styleObj.fontSize : DEFAULT_FONT_SIZE - lineHeight = (parseFloat(lineHeight) / 100) * fontSize - styleObj.lineHeight = lineHeight - } -} - interface TransformStyleConfig { enableVar?: boolean externalVarContext?: Record diff --git a/packages/webpack-plugin/lib/web/processStyles.js b/packages/webpack-plugin/lib/web/processStyles.js index 5b26793e28..99fd631883 100644 --- a/packages/webpack-plugin/lib/web/processStyles.js +++ b/packages/webpack-plugin/lib/web/processStyles.js @@ -8,11 +8,8 @@ module.exports = function (styles, options, callback) { attrs (style) { const attrs = Object.assign({}, style.attrs) if (options.autoScope) attrs.scoped = true - attrs.mpxStyleOptions = JSON.stringify({ - // scoped: !!options.autoScope, - // query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理 - mid: options.moduleId - }) + // query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理 + attrs.mid = options.moduleId return attrs } })