diff --git a/packages/uni-template-compiler/lib/index.js b/packages/uni-template-compiler/lib/index.js index 9c4f61d62861b7e239bf16648ce28f6758f153a5..904536958326df78af65fd78bd9bd5c483637be8 100644 --- a/packages/uni-template-compiler/lib/index.js +++ b/packages/uni-template-compiler/lib/index.js @@ -35,7 +35,13 @@ const { module.exports = { compile (source, options = {}) { - (options.modules || (options.modules = [])).push(autoComponentsModule) + if ( // 启用摇树优化后,需要过滤内置组件 + !options.autoComponentResourcePath || + options.autoComponentResourcePath.indexOf('@dcloudio/uni-h5/src') === -1 + ) { + (options.modules || (options.modules = [])).push(autoComponentsModule) + } + options.isUnaryTag = isUnaryTag // 将 autoComponents 挂在 isUnaryTag 上边 options.isUnaryTag.autoComponents = new Set() @@ -257,4 +263,4 @@ at ${resourcePath}.vue:1`) ssrCompile, ssrCompileToFunctions, generateCodeFrame -} +} diff --git a/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js b/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js index 46a938e2c16f445b50f402fbf46cd34a707ae446..52e5f4118e90183ebc6624dfcba69832cc19323f 100644 --- a/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js +++ b/packages/vue-cli-plugin-uni/packages/vue-loader/lib/index.js @@ -77,8 +77,13 @@ module.exports = function (source) { if (options.isH5TreeShaking) { // 摇树优化逻辑(框架组件移除样式,禁用 modules) const isWin = /^win/.test(process.platform) - const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) + + if(options.compilerOptions){ + options.compilerOptions = {} + } + options.compilerOptions.autoComponentResourcePath = normalizePath(resourcePath) + // fixed by xxxxxx if(!modules && options.compilerOptions && options.compilerOptions.modules){ modules = options.compilerOptions.modules