diff --git a/packages/uni-cli-shared/lib/uni_modules/uni_modules.js b/packages/uni-cli-shared/lib/uni_modules/uni_modules.js index 644dcef90022241678a1f00928518f2725d41403..a2a720523399ad7115ce30546cb0428cd469798b 100644 --- a/packages/uni-cli-shared/lib/uni_modules/uni_modules.js +++ b/packages/uni-cli-shared/lib/uni_modules/uni_modules.js @@ -23,9 +23,13 @@ function parseUniExtApis(vite = true) { if (!fs_extra_1.default.existsSync(pkgPath)) { return; } - const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b['uni-ext-api']; - if (exports) { - Object.assign(injects, parseInjects(vite, process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}`, exports)); + try { + const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b['uni-ext-api']; + if (exports) { + Object.assign(injects, parseInjects(vite, process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}`, exports)); + } + } + catch (e) { } }); return injects; diff --git a/packages/vue-cli-plugin-uni/util/format-errors.js b/packages/vue-cli-plugin-uni/util/format-errors.js index 18565c19f9ab0cd27955c27d36e5a32c3d8b8cf6..4420fb88ff251683cf35b07626b770b2a33993bb 100644 --- a/packages/vue-cli-plugin-uni/util/format-errors.js +++ b/packages/vue-cli-plugin-uni/util/format-errors.js @@ -20,6 +20,8 @@ function formatMessage (msg) { return '' } +const installPreprocessorTips = {} + function ModuleBuildError (err) { const lines = err.message.split('\n') let firstLineMessage = lines[0] @@ -78,6 +80,10 @@ function ModuleBuildError (err) { builtinCompile = 'pug/jade' } if (builtinCompile) { + if (installPreprocessorTips[name]) { + return false + } + installPreprocessorTips[name] = true installHBuilderXPlugin(name) return { message: '预编译器错误:代码使用了' + builtinCompile +