From 6871ce8097e385b618d87fb5657594ba17b4e368 Mon Sep 17 00:00:00 2001 From: luckyadam Date: Wed, 9 Jun 2021 18:49:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugin):=20=E4=BF=AE=E5=A4=8D=E5=9C=A8?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=AD=E6=97=A0=E6=B3=95=E8=B0=83=E7=94=A8?= =?UTF-8?q?=20taro=20api=20=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8Cclose=20#94?= =?UTF-8?q?57?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-loader/src/independentPage.ts | 7 ++++++- packages/taro-loader/src/native-component.ts | 7 ++++++- packages/taro-mini-runner/src/plugins/MiniPlugin.ts | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/taro-loader/src/independentPage.ts b/packages/taro-loader/src/independentPage.ts index ef8d9b2382bc..c75bab47f62e 100644 --- a/packages/taro-loader/src/independentPage.ts +++ b/packages/taro-loader/src/independentPage.ts @@ -29,11 +29,16 @@ export default function (this: webpack.loader.LoaderContext) { const componentPath = isNeedRawLoader ? `${raw}!${this.resourcePath}` : this.request.split('!').slice(1).join('!') + const runtimePath = Array.isArray(options.runtimePath) ? options.runtimePath : [options.runtimePath] + const setReconciler = runtimePath.reduce((res, item) => { + return res + `import '${item}'\n` + }, '') const prerender = ` if (typeof PRERENDER !== 'undefined') { global._prerender = inst }` - return `import { createPageConfig, ${creator}, window } from '@tarojs/runtime' + return `${setReconciler} +import { createPageConfig, ${creator}, window } from '@tarojs/runtime' import component from ${stringify(componentPath)} ${importFrameworkStatement} var config = ${configString}; diff --git a/packages/taro-loader/src/native-component.ts b/packages/taro-loader/src/native-component.ts index 0d904c457799..e4f45810cf6d 100644 --- a/packages/taro-loader/src/native-component.ts +++ b/packages/taro-loader/src/native-component.ts @@ -20,12 +20,17 @@ export default function (this: webpack.loader.LoaderContext) { const componentPath = isNeedRawLoader ? `${raw}!${this.resourcePath}` : this.request.split('!').slice(thisLoaderIndex + 1).join('!') + const runtimePath = Array.isArray(options.runtimePath) ? options.runtimePath : [options.runtimePath] + const setReconciler = runtimePath.reduce((res, item) => { + return res + `import '${item}'\n` + }, '') const prerender = ` if (typeof PRERENDER !== 'undefined') { global._prerender = inst }` - return `import { createNativeComponentConfig } from '@tarojs/runtime' + return `${setReconciler} +import { createNativeComponentConfig } from '@tarojs/runtime' import component from ${stringify(componentPath)} ${importFrameworkStatement} var config = ${configString}; diff --git a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts index d5a96f692e96..e4a013794e4c 100644 --- a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts +++ b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts @@ -282,7 +282,8 @@ export default class TaroMiniPlugin { name: module.name, prerender: this.prerenderPages.has(module.name), config: this.filesConfig, - appConfig: this.appConfig + appConfig: this.appConfig, + runtimePath: this.options.runtimePath } }) } @@ -294,7 +295,8 @@ export default class TaroMiniPlugin { options: { framework, name: module.name, - prerender: this.prerenderPages.has(module.name) + prerender: this.prerenderPages.has(module.name), + runtimePath: this.options.runtimePath } }) }