diff --git a/packages/uni-mp-alipay/src/compiler/options.ts b/packages/uni-mp-alipay/src/compiler/options.ts index af72796bae..0ce7fa518a 100644 --- a/packages/uni-mp-alipay/src/compiler/options.ts +++ b/packages/uni-mp-alipay/src/compiler/options.ts @@ -166,6 +166,7 @@ export const options: UniMiniProgramPluginOptions = { app: { darkmode: false, subpackages: true, + independentSubpackages: true, plugins: true, usingComponents: true, normalize(appJson) { diff --git a/packages/uni-mp-alipay/src/runtime/index.ts b/packages/uni-mp-alipay/src/runtime/index.ts index 47988f0057..655934311e 100644 --- a/packages/uni-mp-alipay/src/runtime/index.ts +++ b/packages/uni-mp-alipay/src/runtime/index.ts @@ -2,6 +2,7 @@ import { EventChannel } from '@dcloudio/uni-shared' import { initCreateApp, + initCreateIndependentSubpackageApp, initCreatePluginApp, initCreateSubpackageApp, } from '@dcloudio/uni-mp-core' @@ -12,14 +13,26 @@ import * as parseAppOptions from './parseAppOptions' import { initCreatePage } from './createPage' import { initCreateComponent } from './createComponent' + +declare const __UNI_MP_INDEPENDENT_RUNTIME__: boolean + export const createApp = initCreateApp(parseAppOptions) export const createPage = initCreatePage() export const createComponent = initCreateComponent() export const createPluginApp = initCreatePluginApp(parseAppOptions) export const createSubpackageApp = initCreateSubpackageApp(parseAppOptions) -;(my as any).EventChannel = EventChannel -;(my as any).createApp = createApp -;(my as any).createPage = createPage -;(my as any).createComponent = createComponent -;(my as any).createPluginApp = createPluginApp -;(my as any).createSubpackageApp = createSubpackageApp +export const createIndependentSubpackageApp = + initCreateIndependentSubpackageApp() + +const isIndependentRuntime = + typeof __UNI_MP_INDEPENDENT_RUNTIME__ !== 'undefined' && + __UNI_MP_INDEPENDENT_RUNTIME__ === true +if (!isIndependentRuntime) { + ;(my as any).EventChannel = EventChannel + ;(my as any).createApp = createApp + ;(my as any).createPage = createPage + ;(my as any).createComponent = createComponent + ;(my as any).createPluginApp = createPluginApp + ;(my as any).createSubpackageApp = createSubpackageApp + ;(my as any).createIndependentSubpackageApp = createIndependentSubpackageApp +}