diff --git a/examples/build-weapp-plugin/src/app.config.ts b/examples/build-weapp-plugin/src/app.config.ts
index d48f328bec78..86c28d96b9d0 100644
--- a/examples/build-weapp-plugin/src/app.config.ts
+++ b/examples/build-weapp-plugin/src/app.config.ts
@@ -17,8 +17,8 @@ export default {
'mp-comp': 'component/comp'
}
},
- // 需要配置 copy,复制 my-export.js 到 miniprogram/miniprogram
- export: 'my-export.js'
+ // 自动编译输出
+ export: 'plugin-export'
}
}
}
diff --git a/examples/build-weapp-plugin/src/my-export.js b/examples/build-weapp-plugin/src/my-export.js
deleted file mode 100644
index d5e6a9ca1f8d..000000000000
--- a/examples/build-weapp-plugin/src/my-export.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = { whoami: 'Wechat MiniProgram' }
diff --git a/examples/build-weapp-plugin/src/plugin-export.ts b/examples/build-weapp-plugin/src/plugin-export.ts
new file mode 100644
index 000000000000..cfb04a313c10
--- /dev/null
+++ b/examples/build-weapp-plugin/src/plugin-export.ts
@@ -0,0 +1 @@
+export default { whoami: 'Wechat MiniProgram' }
diff --git a/packages/taro-mini-runner/src/__tests__/__snapshots__/plugin-export.spec.ts.snap b/packages/taro-mini-runner/src/__tests__/__snapshots__/plugin-export.spec.ts.snap
new file mode 100644
index 000000000000..b6c625aaf91c
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/__snapshots__/plugin-export.spec.ts.snap
@@ -0,0 +1,2313 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`plugin-export should build plugin export files 1`] = `26`;
+
+exports[`plugin-export should build plugin export files 2`] = `
+"
+/** filePath: dist/app.js **/
+require(\\"./runtime\\");
+
+require(\\"./common\\");
+
+require(\\"./vendors\\");
+
+require(\\"./taro\\");
+
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 4 ], {
+ 14: function(module, exports, __webpack_require__) {},
+ 21: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ var mocks_taro = \\"taro\\";
+ function mergeReconciler() {}
+ function mergeInternalComponents() {}
+ function isFunction() {}
+ function isArray() {}
+ function processApis() {}
+ var EMPTY_OBJ = {};
+ var hooks = {};
+ function setReconciler() {}
+ function connectReactPage() {}
+ function createReactApp() {}
+ function createNativeComponentConfig() {}
+ function connectVuePage() {}
+ function createVueApp() {}
+ function createVue3App() {}
+ var setGlobalDataPlugin = {};
+ function useDidHide() {}
+ function useDidShow() {}
+ function useError() {}
+ function useLaunch() {}
+ function usePageNotFound() {}
+ function useLoad() {}
+ function usePageScroll() {}
+ function usePullDownRefresh() {}
+ function usePullIntercept() {}
+ function useReachBottom() {}
+ function useResize() {}
+ function useUnload() {}
+ function useAddToFavorites() {}
+ function useOptionMenuClick() {}
+ function useSaveExitState() {}
+ function useShareAppMessage() {}
+ function useShareTimeline() {}
+ function useTitleClick() {}
+ function useReady() {}
+ function useRouter() {}
+ function useTabItemTap() {}
+ function useScope() {}
+ var needPromiseApis = new Set([ \\"authPrivateMessage\\", \\"disableAlertBeforeUnload\\", \\"enableAlertBeforeUnload\\", \\"getBackgroundFetchData\\", \\"getGroupEnterInfo\\", \\"getShareInfo\\", \\"getWeRunData\\", \\"join1v1Chat\\", \\"openVideoEditor\\", \\"saveFileToDisk\\", \\"scanItem\\", \\"setEnable1v1Chat\\", \\"setWindowSize\\", \\"sendBizRedPacket\\", \\"startFacialRecognitionVerify\\", \\"openCustomerServiceChat\\", \\"getLocalIPAddress\\", \\"getUserProfile\\", \\"editImage\\", \\"getFuzzyLocation\\", \\"cropImage\\" ]);
+ function initNativeApi(taro) {
+ processApis(taro, wx, {
+ needPromiseApis: needPromiseApis,
+ modifyApis: function modifyApis(apis) {
+ apis.delete(\\"lanDebug\\");
+ },
+ transformMeta: function transformMeta(api, options) {
+ var _a;
+ if (api === \\"showShareMenu\\") {
+ options.menus = (_a = options.showShareItems) === null || _a === void 0 ? void 0 : _a.map((function(item) {
+ return item === \\"wechatFriends\\" ? \\"shareAppMessage\\" : item === \\"wechatMoment\\" ? \\"shareTimeline\\" : item;
+ }));
+ }
+ return {
+ key: api,
+ options: options
+ };
+ }
+ });
+ taro.cloud = wx.cloud;
+ taro.getTabBar = function(pageCtx) {
+ var _a;
+ if (typeof (pageCtx === null || pageCtx === void 0 ? void 0 : pageCtx.getTabBar) === \\"function\\") {
+ return (_a = pageCtx.getTabBar()) === null || _a === void 0 ? void 0 : _a.$taroInstances;
+ }
+ };
+ }
+ var _true = \\"true\\";
+ var _false = \\"false\\";
+ var _empty = \\"\\";
+ var _zero = \\"0\\";
+ var components = {
+ Progress: {
+ \\"border-radius\\": _zero,
+ \\"font-size\\": \\"16\\",
+ duration: \\"30\\",
+ bindActiveEnd: _empty
+ },
+ RichText: {
+ space: _empty,
+ \\"user-select\\": _false
+ },
+ Text: {
+ \\"user-select\\": _false
+ },
+ Map: {
+ polygons: \\"[]\\",
+ subkey: _empty,
+ rotate: _zero,
+ skew: _zero,
+ \\"max-scale\\": \\"20\\",
+ \\"min-scale\\": \\"3\\",
+ \\"enable-3D\\": _false,
+ \\"show-compass\\": _false,
+ \\"show-scale\\": _false,
+ \\"enable-overlooking\\": _false,
+ \\"enable-zoom\\": _true,
+ \\"enable-scroll\\": _true,
+ \\"enable-rotate\\": _false,
+ \\"enable-satellite\\": _false,
+ \\"enable-traffic\\": _false,
+ \\"enable-poi\\": _true,
+ \\"enable-building\\": _true,
+ setting: \\"[]\\",
+ bindLabelTap: _empty,
+ bindRegionChange: _empty,
+ bindPoiTap: _empty,
+ bindAnchorPointTap: _empty
+ },
+ Button: {
+ lang: \\"en\\",
+ \\"session-from\\": _empty,
+ \\"send-message-title\\": _empty,
+ \\"send-message-path\\": _empty,
+ \\"send-message-img\\": _empty,
+ \\"app-parameter\\": _empty,
+ \\"show-message-card\\": _false,
+ \\"business-id\\": _empty,
+ bindGetUserInfo: _empty,
+ bindContact: _empty,
+ bindGetPhoneNumber: _empty,
+ bindChooseAvatar: _empty,
+ bindError: _empty,
+ bindOpenSetting: _empty,
+ bindLaunchApp: _empty
+ },
+ Form: {
+ \\"report-submit-timeout\\": _zero
+ },
+ Input: {
+ \\"always-embed\\": _false,
+ \\"adjust-position\\": _true,
+ \\"hold-keyboard\\": _false,
+ \\"safe-password-cert-path\\": \\"\\",
+ \\"safe-password-length\\": \\"\\",
+ \\"safe-password-time-stamp\\": \\"\\",
+ \\"safe-password-nonce\\": \\"\\",
+ \\"safe-password-salt\\": \\"\\",
+ \\"safe-password-custom-hash\\": \\"\\",
+ \\"auto-fill\\": _empty,
+ bindKeyboardHeightChange: _empty
+ },
+ Picker: {
+ \\"header-text\\": _empty
+ },
+ PickerView: {
+ \\"immediate-change\\": _false,
+ bindPickStart: _empty,
+ bindPickEnd: _empty
+ },
+ Slider: {
+ color: \\"'#e9e9e9'\\",
+ \\"selected-color\\": \\"'#1aad19'\\"
+ },
+ Textarea: {
+ \\"show-confirm-bar\\": _true,
+ \\"adjust-position\\": _true,
+ \\"hold-keyboard\\": _false,
+ \\"disable-default-padding\\": _false,
+ \\"confirm-type\\": \\"'return'\\",
+ \\"confirm-hold\\": _false,
+ bindKeyboardHeightChange: _empty
+ },
+ ScrollView: {
+ \\"enable-flex\\": _false,
+ \\"scroll-anchoring\\": _false,
+ \\"refresher-enabled\\": _false,
+ \\"refresher-threshold\\": \\"45\\",
+ \\"refresher-default-style\\": \\"'black'\\",
+ \\"refresher-background\\": \\"'#FFF'\\",
+ \\"refresher-triggered\\": _false,
+ enhanced: _false,
+ bounces: _true,
+ \\"show-scrollbar\\": _true,
+ \\"paging-enabled\\": _false,
+ \\"fast-deceleration\\": _false,
+ bindDragStart: _empty,
+ bindDragging: _empty,
+ bindDragEnd: _empty,
+ bindRefresherPulling: _empty,
+ bindRefresherRefresh: _empty,
+ bindRefresherRestore: _empty,
+ bindRefresherAbort: _empty
+ },
+ Swiper: {
+ \\"snap-to-edge\\": _false,
+ \\"easing-function\\": \\"'default'\\"
+ },
+ SwiperItem: {
+ \\"skip-hidden-item-layout\\": _false
+ },
+ Navigator: {
+ target: \\"'self'\\",
+ \\"app-id\\": _empty,
+ path: _empty,
+ \\"extra-data\\": _empty,
+ version: \\"'version'\\"
+ },
+ Camera: {
+ mode: \\"'normal'\\",
+ resolution: \\"'medium'\\",
+ \\"frame-size\\": \\"'medium'\\",
+ bindInitDone: _empty,
+ bindScanCode: _empty
+ },
+ Image: {
+ webp: _false,
+ \\"show-menu-by-longpress\\": _false
+ },
+ LivePlayer: {
+ mode: \\"'live'\\",
+ \\"sound-mode\\": \\"'speaker'\\",
+ \\"auto-pause-if-navigate\\": _true,
+ \\"auto-pause-if-open-native\\": _true,
+ \\"picture-in-picture-mode\\": \\"[]\\",
+ bindstatechange: _empty,
+ bindfullscreenchange: _empty,
+ bindnetstatus: _empty,
+ bindAudioVolumeNotify: _empty,
+ bindEnterPictureInPicture: _empty,
+ bindLeavePictureInPicture: _empty
+ },
+ Video: {
+ title: _empty,
+ \\"play-btn-position\\": \\"'bottom'\\",
+ \\"enable-play-gesture\\": _false,
+ \\"auto-pause-if-navigate\\": _true,
+ \\"auto-pause-if-open-native\\": _true,
+ \\"vslide-gesture\\": _false,
+ \\"vslide-gesture-in-fullscreen\\": _true,
+ \\"ad-unit-id\\": _empty,
+ \\"poster-for-crawler\\": _empty,
+ \\"show-casting-button\\": _false,
+ \\"picture-in-picture-mode\\": \\"[]\\",
+ \\"enable-auto-rotation\\": _false,
+ \\"show-screen-lock-button\\": _false,
+ \\"show-snapshot-button\\": _false,
+ \\"show-background-playback-button\\": _false,
+ \\"background-poster\\": _empty,
+ bindProgress: _empty,
+ bindLoadedMetadata: _empty,
+ bindControlsToggle: _empty,
+ bindEnterPictureInPicture: _empty,
+ bindLeavePictureInPicture: _empty,
+ bindSeekComplete: _empty,
+ bindAdLoad: _empty,
+ bindAdError: _empty,
+ bindAdClose: _empty,
+ bindAdPlay: _empty
+ },
+ Canvas: {
+ type: _empty
+ },
+ Ad: {
+ \\"ad-type\\": \\"'banner'\\",
+ \\"ad-theme\\": \\"'white'\\"
+ },
+ CoverView: {
+ \\"marker-id\\": _empty,
+ slot: _empty
+ },
+ Editor: {
+ \\"read-only\\": _false,
+ placeholder: _empty,
+ \\"show-img-size\\": _false,
+ \\"show-img-toolbar\\": _false,
+ \\"show-img-resize\\": _false,
+ focus: _false,
+ bindReady: _empty,
+ bindFocus: _empty,
+ bindBlur: _empty,
+ bindInput: _empty,
+ bindStatusChange: _empty,
+ name: _empty
+ },
+ MatchMedia: {
+ \\"min-width\\": _empty,
+ \\"max-width\\": _empty,
+ width: _empty,
+ \\"min-height\\": _empty,
+ \\"max-height\\": _empty,
+ height: _empty,
+ orientation: _empty
+ },
+ FunctionalPageNavigator: {
+ version: \\"'release'\\",
+ name: _empty,
+ args: _empty,
+ bindSuccess: _empty,
+ bindFail: _empty,
+ bindCancel: _empty
+ },
+ LivePusher: {
+ url: _empty,
+ mode: \\"'RTC'\\",
+ autopush: _false,
+ muted: _false,
+ \\"enable-camera\\": _true,
+ \\"auto-focus\\": _true,
+ orientation: \\"'vertical'\\",
+ beauty: _zero,
+ whiteness: _zero,
+ aspect: \\"'9:16'\\",
+ \\"min-bitrate\\": \\"200\\",
+ \\"max-bitrate\\": \\"1000\\",
+ \\"audio-quality\\": \\"'high'\\",
+ \\"waiting-image\\": _empty,
+ \\"waiting-image-hash\\": _empty,
+ zoom: _false,
+ \\"device-position\\": \\"'front'\\",
+ \\"background-mute\\": _false,
+ mirror: _false,
+ \\"remote-mirror\\": _false,
+ \\"local-mirror\\": _false,
+ \\"audio-reverb-type\\": _zero,
+ \\"enable-mic\\": _true,
+ \\"enable-agc\\": _false,
+ \\"enable-ans\\": _false,
+ \\"audio-volume-type\\": \\"'voicecall'\\",
+ \\"video-width\\": \\"360\\",
+ \\"video-height\\": \\"640\\",
+ \\"beauty-style\\": \\"'smooth'\\",
+ filter: \\"'standard'\\",
+ animation: _empty,
+ bindStateChange: _empty,
+ bindNetStatus: _empty,
+ bindBgmStart: _empty,
+ bindBgmProgress: _empty,
+ bindBgmComplete: _empty,
+ bindAudioVolumeNotify: _empty
+ },
+ OfficialAccount: {
+ bindLoad: _empty,
+ bindError: _empty
+ },
+ OpenData: {
+ type: _empty,
+ \\"open-gid\\": _empty,
+ lang: \\"'en'\\",
+ \\"default-text\\": _empty,
+ \\"default-avatar\\": _empty,
+ bindError: _empty
+ },
+ NavigationBar: {
+ title: _empty,
+ loading: _false,
+ \\"front-color\\": _empty,
+ \\"background-color\\": _empty,
+ \\"color-animation-duration\\": _zero,
+ \\"color-animation-timing-func\\": \\"'linear'\\"
+ },
+ PageMeta: {
+ \\"background-text-style\\": _empty,
+ \\"background-color\\": _empty,
+ \\"background-color-top\\": _empty,
+ \\"background-color-bottom\\": _empty,
+ \\"scroll-top\\": \\"''\\",
+ \\"scroll-duration\\": \\"300\\",
+ \\"page-style\\": \\"''\\",
+ \\"root-font-size\\": \\"''\\",
+ bindResize: _empty,
+ bindScroll: _empty,
+ bindScrollDone: _empty
+ },
+ VoipRoom: {
+ openid: _empty,
+ mode: \\"'camera'\\",
+ \\"device-position\\": \\"'front'\\",
+ bindError: _empty
+ },
+ AdCustom: {
+ \\"unit-id\\": _empty,
+ \\"ad-intervals\\": _empty,
+ bindLoad: _empty,
+ bindError: _empty
+ },
+ PageContainer: {
+ show: _false,
+ duration: \\"300\\",
+ \\"z-index\\": \\"100\\",
+ overlay: _true,
+ position: \\"'bottom'\\",
+ round: _false,
+ \\"close-on-slideDown\\": _false,
+ \\"overlay-style\\": _empty,
+ \\"custom-style\\": _empty,
+ bindBeforeEnter: _empty,
+ bindEnter: _empty,
+ bindAfterEnter: _empty,
+ bindBeforeLeave: _empty,
+ bindLeave: _empty,
+ bindAfterLeave: _empty,
+ bindClickOverlay: _empty
+ },
+ ShareElement: {
+ mapkey: _empty,
+ transform: _false,
+ duration: \\"300\\",
+ \\"easing-function\\": \\"'ease-out'\\"
+ },
+ KeyboardAccessory: {},
+ RootPortal: {}
+ };
+ var hostConfig = {
+ initNativeApi: initNativeApi,
+ getMiniLifecycle: function getMiniLifecycle(config) {
+ var methods = config.page[5];
+ if (methods.indexOf(\\"onSaveExitState\\") === -1) {
+ methods.push(\\"onSaveExitState\\");
+ }
+ return config;
+ }
+ };
+ mergeReconciler(hostConfig);
+ mergeInternalComponents(components);
+ var taro_runtime = __webpack_require__(2);
+ var classCallCheck = __webpack_require__(3);
+ var createClass = __webpack_require__(4);
+ var inherits = __webpack_require__(6);
+ var createSuper = __webpack_require__(5);
+ var react = __webpack_require__(0);
+ var app = __webpack_require__(14);
+ var app_App = function(_Component) {
+ Object(inherits[\\"a\\"])(App, _Component);
+ var _super = Object(createSuper[\\"a\\"])(App);
+ function App() {
+ Object(classCallCheck[\\"a\\"])(this, App);
+ return _super.apply(this, arguments);
+ }
+ Object(createClass[\\"a\\"])(App, [ {
+ key: \\"componentDidMount\\",
+ value: function componentDidMount() {}
+ }, {
+ key: \\"componentDidShow\\",
+ value: function componentDidShow() {}
+ }, {
+ key: \\"componentDidHide\\",
+ value: function componentDidHide() {}
+ }, {
+ key: \\"render\\",
+ value: function render() {
+ return this.props.children;
+ }
+ } ]);
+ return App;
+ }(react[\\"Component\\"]);
+ var lib_src_app = app_App;
+ var taro_react = __webpack_require__(9);
+ var config = {
+ pages: [ \\"pages/index/index\\" ],
+ window: {
+ backgroundTextStyle: \\"light\\",
+ navigationBarBackgroundColor: \\"#fff\\",
+ navigationBarTitleText: \\"WeChat\\",
+ navigationBarTextStyle: \\"black\\"
+ },
+ plugins: {
+ testPlugin: {
+ version: \\"dev\\",
+ provider: \\"xxx\\",
+ export: \\"index\\"
+ }
+ },
+ subpackages: [ {
+ root: \\"packageA\\",
+ pages: [ \\"detail/index\\", \\"my/index\\" ],
+ plugins: {
+ testSubPackagePlugin: {
+ version: \\"dev\\",
+ provider: \\"xxx\\",
+ export: \\"index\\"
+ }
+ }
+ } ]
+ };
+ taro_runtime[\\"window\\"].__taroAppConfig = config;
+ var inst = App(createReactApp(lib_src_app, react, taro_react[\\"a\\"], config));
+ undefined({
+ designWidth: 750,
+ deviceRatio: {
+ 640: 1.17,
+ 750: 1,
+ 828: .905
+ }
+ });
+ }
+}, [ [ 21, 0, 1, 3, 2 ] ] ]);
+
+
+
+/** filePath: dist/app.json **/
+{\\"pages\\":[\\"pages/index/index\\"],\\"window\\":{\\"backgroundTextStyle\\":\\"light\\",\\"navigationBarBackgroundColor\\":\\"#fff\\",\\"navigationBarTitleText\\":\\"WeChat\\",\\"navigationBarTextStyle\\":\\"black\\"},\\"plugins\\":{\\"testPlugin\\":{\\"version\\":\\"dev\\",\\"provider\\":\\"xxx\\",\\"export\\":\\"index\\"}},\\"subpackages\\":[{\\"root\\":\\"packageA\\",\\"pages\\":[\\"detail/index\\",\\"my/index\\"],\\"plugins\\":{\\"testSubPackagePlugin\\":{\\"version\\":\\"dev\\",\\"provider\\":\\"xxx\\",\\"export\\":\\"index\\"}}}]}
+
+/** filePath: dist/app.wxss **/
+
+
+/** filePath: dist/base.wxml **/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{i.v}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/** filePath: dist/common.js **/
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 2 ], {
+ 0: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ __webpack_exports__[\\"default\\"] = \\"react-mock\\";
+ },
+ 8: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.d(__webpack_exports__, \\"a\\", (function() {
+ return someCommon;
+ }));
+ function someCommon(text) {
+ console.log(\\"log something: \\", text);
+ }
+ }
+} ]);
+
+/** filePath: dist/comp.js **/
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 6 ], {
+ 15: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
+ Component(Object(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__[\\"createRecursiveComponentConfig\\"])());
+ }
+}, [ [ 15, 0, 1 ] ] ]);
+
+/** filePath: dist/comp.json **/
+{\\"component\\":true,\\"usingComponents\\":{\\"comp\\":\\"./comp\\"}}
+
+/** filePath: dist/comp.wxml **/
+
+
+
+/** filePath: dist/index.js **/
+module.exports = (wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 8 ], {
+ 19: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ __webpack_require__.d(__webpack_exports__, \\"hello\\", (function() {
+ return hello;
+ }));
+ function hello() {
+ console.log(\\"hello from mini\\");
+ }
+ }
+}, [ [ 19, 0 ] ] ]);
+
+/** filePath: dist/packageA/detail/index.js **/
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 9 ], {
+ 18: function(module, exports, __webpack_require__) {},
+ 23: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ var taro_runtime = __webpack_require__(2);
+ var classCallCheck = __webpack_require__(3);
+ var createClass = __webpack_require__(4);
+ var inherits = __webpack_require__(6);
+ var createSuper = __webpack_require__(5);
+ var react = __webpack_require__(0);
+ var taro_components = __webpack_require__(1);
+ var common = __webpack_require__(8);
+ var detail = __webpack_require__(18);
+ var detail_Detail = function(_Component) {
+ Object(inherits[\\"a\\"])(Detail, _Component);
+ var _super = Object(createSuper[\\"a\\"])(Detail);
+ function Detail() {
+ Object(classCallCheck[\\"a\\"])(this, Detail);
+ return _super.apply(this, arguments);
+ }
+ Object(createClass[\\"a\\"])(Detail, [ {
+ key: \\"componentDidMount\\",
+ value: function componentDidMount() {
+ Object(common[\\"a\\"])(\\"detail\\");
+ }
+ }, {
+ key: \\"render\\",
+ value: function render() {
+ return react[\\"default\\"].createElement(taro_components[\\"View\\"], {
+ className: \\"detail\\"
+ }, react[\\"default\\"].createElement(taro_components[\\"Text\\"], null, \\"I m detail\\"));
+ }
+ } ]);
+ return Detail;
+ }(react[\\"Component\\"]);
+ var config = {
+ navigationBarTitleText: \\"\\\\u8be6\\\\u60c5\\\\u9875\\"
+ };
+ var inst = Page(Object(taro_runtime[\\"createPageConfig\\"])(detail_Detail, \\"packageA/detail/index\\", {
+ root: {
+ cn: []
+ }
+ }, config || {}));
+ }
+}, [ [ 23, 0, 1, 3, 2 ] ] ]);
+
+/** filePath: dist/packageA/detail/index.json **/
+{\\"navigationBarTitleText\\":\\"详情页\\",\\"usingComponents\\":{\\"comp\\":\\"../../comp\\"}}
+
+/** filePath: dist/packageA/detail/index.wxml **/
+
+
+
+/** filePath: dist/packageA/detail/index.wxss **/
+.detail{width:100%;height:100%}
+
+/** filePath: dist/packageA/index.js **/
+module.exports = (wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 11 ], {
+ 20: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ __webpack_require__.d(__webpack_exports__, \\"hello\\", (function() {
+ return hello;
+ }));
+ function hello() {
+ console.log(\\"hello from mini sub package\\");
+ }
+ }
+}, [ [ 20, 0 ] ] ]);
+
+/** filePath: dist/packageA/my/index.js **/
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 12 ], {
+ 24: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ var taro_runtime = __webpack_require__(2);
+ var classCallCheck = __webpack_require__(3);
+ var createClass = __webpack_require__(4);
+ var inherits = __webpack_require__(6);
+ var createSuper = __webpack_require__(5);
+ var react = __webpack_require__(0);
+ var taro_components = __webpack_require__(1);
+ var common = __webpack_require__(8);
+ var my_My = function(_Component) {
+ Object(inherits[\\"a\\"])(My, _Component);
+ var _super = Object(createSuper[\\"a\\"])(My);
+ function My() {
+ Object(classCallCheck[\\"a\\"])(this, My);
+ return _super.apply(this, arguments);
+ }
+ Object(createClass[\\"a\\"])(My, [ {
+ key: \\"componentDidMount\\",
+ value: function componentDidMount() {
+ Object(common[\\"a\\"])(\\"my\\");
+ }
+ }, {
+ key: \\"render\\",
+ value: function render() {
+ return react[\\"default\\"].createElement(taro_components[\\"View\\"], null, react[\\"default\\"].createElement(taro_components[\\"Text\\"], null, \\"I m my\\"));
+ }
+ } ]);
+ return My;
+ }(react[\\"Component\\"]);
+ var config = {
+ navigationBarTitleText: \\"\\\\u4e2a\\\\u4eba\\\\u4e2d\\\\u5fc3\\\\u9875\\"
+ };
+ var inst = Page(Object(taro_runtime[\\"createPageConfig\\"])(my_My, \\"packageA/my/index\\", {
+ root: {
+ cn: []
+ }
+ }, config || {}));
+ }
+}, [ [ 24, 0, 1, 3, 2 ] ] ]);
+
+/** filePath: dist/packageA/my/index.json **/
+{\\"navigationBarTitleText\\":\\"个人中心页\\",\\"usingComponents\\":{\\"comp\\":\\"../../comp\\"}}
+
+/** filePath: dist/packageA/my/index.wxml **/
+
+
+
+/** filePath: dist/pages/index/index.js **/
+/*! For license information please see index.js.LICENSE.txt */
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 14 ], {
+ 17: function(module, exports, __webpack_require__) {},
+ 22: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.r(__webpack_exports__);
+ var taro_runtime = __webpack_require__(2);
+ var esm_typeof = __webpack_require__(7);
+ function _regeneratorRuntime() {
+ \\"use strict\\";
+ _regeneratorRuntime = function _regeneratorRuntime() {
+ return exports;
+ };
+ var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = \\"function\\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \\"@@iterator\\", asyncIteratorSymbol = $Symbol.asyncIterator || \\"@@asyncIterator\\", toStringTagSymbol = $Symbol.toStringTag || \\"@@toStringTag\\";
+ function define(obj, key, value) {
+ return Object.defineProperty(obj, key, {
+ value: value,
+ enumerable: !0,
+ configurable: !0,
+ writable: !0
+ }), obj[key];
+ }
+ try {
+ define({}, \\"\\");
+ } catch (err) {
+ define = function define(obj, key, value) {
+ return obj[key] = value;
+ };
+ }
+ function wrap(innerFn, outerFn, self, tryLocsList) {
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
+ return generator._invoke = function(innerFn, self, context) {
+ var state = \\"suspendedStart\\";
+ return function(method, arg) {
+ if (\\"executing\\" === state) throw new Error(\\"Generator is already running\\");
+ if (\\"completed\\" === state) {
+ if (\\"throw\\" === method) throw arg;
+ return doneResult();
+ }
+ for (context.method = method, context.arg = arg; ;) {
+ var delegate = context.delegate;
+ if (delegate) {
+ var delegateResult = maybeInvokeDelegate(delegate, context);
+ if (delegateResult) {
+ if (delegateResult === ContinueSentinel) continue;
+ return delegateResult;
+ }
+ }
+ if (\\"next\\" === context.method) context.sent = context._sent = context.arg; else if (\\"throw\\" === context.method) {
+ if (\\"suspendedStart\\" === state) throw state = \\"completed\\", context.arg;
+ context.dispatchException(context.arg);
+ } else \\"return\\" === context.method && context.abrupt(\\"return\\", context.arg);
+ state = \\"executing\\";
+ var record = tryCatch(innerFn, self, context);
+ if (\\"normal\\" === record.type) {
+ if (state = context.done ? \\"completed\\" : \\"suspendedYield\\", record.arg === ContinueSentinel) continue;
+ return {
+ value: record.arg,
+ done: context.done
+ };
+ }
+ \\"throw\\" === record.type && (state = \\"completed\\", context.method = \\"throw\\", context.arg = record.arg);
+ }
+ };
+ }(innerFn, self, context), generator;
+ }
+ function tryCatch(fn, obj, arg) {
+ try {
+ return {
+ type: \\"normal\\",
+ arg: fn.call(obj, arg)
+ };
+ } catch (err) {
+ return {
+ type: \\"throw\\",
+ arg: err
+ };
+ }
+ }
+ exports.wrap = wrap;
+ var ContinueSentinel = {};
+ function Generator() {}
+ function GeneratorFunction() {}
+ function GeneratorFunctionPrototype() {}
+ var IteratorPrototype = {};
+ define(IteratorPrototype, iteratorSymbol, (function() {
+ return this;
+ }));
+ var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
+ function defineIteratorMethods(prototype) {
+ [ \\"next\\", \\"throw\\", \\"return\\" ].forEach((function(method) {
+ define(prototype, method, (function(arg) {
+ return this._invoke(method, arg);
+ }));
+ }));
+ }
+ function AsyncIterator(generator, PromiseImpl) {
+ function invoke(method, arg, resolve, reject) {
+ var record = tryCatch(generator[method], generator, arg);
+ if (\\"throw\\" !== record.type) {
+ var result = record.arg, value = result.value;
+ return value && \\"object\\" == Object(esm_typeof[\\"a\\"])(value) && hasOwn.call(value, \\"__await\\") ? PromiseImpl.resolve(value.__await).then((function(value) {
+ invoke(\\"next\\", value, resolve, reject);
+ }), (function(err) {
+ invoke(\\"throw\\", err, resolve, reject);
+ })) : PromiseImpl.resolve(value).then((function(unwrapped) {
+ result.value = unwrapped, resolve(result);
+ }), (function(error) {
+ return invoke(\\"throw\\", error, resolve, reject);
+ }));
+ }
+ reject(record.arg);
+ }
+ var previousPromise;
+ this._invoke = function(method, arg) {
+ function callInvokeWithMethodAndArg() {
+ return new PromiseImpl((function(resolve, reject) {
+ invoke(method, arg, resolve, reject);
+ }));
+ }
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
+ };
+ }
+ function maybeInvokeDelegate(delegate, context) {
+ var method = delegate.iterator[context.method];
+ if (undefined === method) {
+ if (context.delegate = null, \\"throw\\" === context.method) {
+ if (delegate.iterator[\\"return\\"] && (context.method = \\"return\\", context.arg = undefined,
+ maybeInvokeDelegate(delegate, context), \\"throw\\" === context.method)) return ContinueSentinel;
+ context.method = \\"throw\\", context.arg = new TypeError(\\"The iterator does not provide a 'throw' method\\");
+ }
+ return ContinueSentinel;
+ }
+ var record = tryCatch(method, delegate.iterator, context.arg);
+ if (\\"throw\\" === record.type) return context.method = \\"throw\\", context.arg = record.arg,
+ context.delegate = null, ContinueSentinel;
+ var info = record.arg;
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc,
+ \\"return\\" !== context.method && (context.method = \\"next\\", context.arg = undefined),
+ context.delegate = null, ContinueSentinel) : info : (context.method = \\"throw\\", context.arg = new TypeError(\\"iterator result is not an object\\"),
+ context.delegate = null, ContinueSentinel);
+ }
+ function pushTryEntry(locs) {
+ var entry = {
+ tryLoc: locs[0]
+ };
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2],
+ entry.afterLoc = locs[3]), this.tryEntries.push(entry);
+ }
+ function resetTryEntry(entry) {
+ var record = entry.completion || {};
+ record.type = \\"normal\\", delete record.arg, entry.completion = record;
+ }
+ function Context(tryLocsList) {
+ this.tryEntries = [ {
+ tryLoc: \\"root\\"
+ } ], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
+ }
+ function values(iterable) {
+ if (iterable) {
+ var iteratorMethod = iterable[iteratorSymbol];
+ if (iteratorMethod) return iteratorMethod.call(iterable);
+ if (\\"function\\" == typeof iterable.next) return iterable;
+ if (!isNaN(iterable.length)) {
+ var i = -1, next = function next() {
+ for (;++i < iterable.length; ) {
+ if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
+ }
+ return next.value = undefined, next.done = !0, next;
+ };
+ return next.next = next;
+ }
+ }
+ return {
+ next: doneResult
+ };
+ }
+ function doneResult() {
+ return {
+ value: undefined,
+ done: !0
+ };
+ }
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, \\"constructor\\", GeneratorFunctionPrototype),
+ define(GeneratorFunctionPrototype, \\"constructor\\", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \\"GeneratorFunction\\"),
+ exports.isGeneratorFunction = function(genFun) {
+ var ctor = \\"function\\" == typeof genFun && genFun.constructor;
+ return !!ctor && (ctor === GeneratorFunction || \\"GeneratorFunction\\" === (ctor.displayName || ctor.name));
+ }, exports.mark = function(genFun) {
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype,
+ define(genFun, toStringTagSymbol, \\"GeneratorFunction\\")), genFun.prototype = Object.create(Gp),
+ genFun;
+ }, exports.awrap = function(arg) {
+ return {
+ __await: arg
+ };
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, (function() {
+ return this;
+ })), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then((function(result) {
+ return result.done ? result.value : iter.next();
+ }));
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \\"Generator\\"), define(Gp, iteratorSymbol, (function() {
+ return this;
+ })), define(Gp, \\"toString\\", (function() {
+ return \\"[object Generator]\\";
+ })), exports.keys = function(object) {
+ var keys = [];
+ for (var key in object) {
+ keys.push(key);
+ }
+ return keys.reverse(), function next() {
+ for (;keys.length; ) {
+ var key = keys.pop();
+ if (key in object) return next.value = key, next.done = !1, next;
+ }
+ return next.done = !0, next;
+ };
+ }, exports.values = values, Context.prototype = {
+ constructor: Context,
+ reset: function reset(skipTempReset) {
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1,
+ this.delegate = null, this.method = \\"next\\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry),
+ !skipTempReset) for (var name in this) {
+ \\"t\\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
+ }
+ },
+ stop: function stop() {
+ this.done = !0;
+ var rootRecord = this.tryEntries[0].completion;
+ if (\\"throw\\" === rootRecord.type) throw rootRecord.arg;
+ return this.rval;
+ },
+ dispatchException: function dispatchException(exception) {
+ if (this.done) throw exception;
+ var context = this;
+ function handle(loc, caught) {
+ return record.type = \\"throw\\", record.arg = exception, context.next = loc, caught && (context.method = \\"next\\",
+ context.arg = undefined), !!caught;
+ }
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i], record = entry.completion;
+ if (\\"root\\" === entry.tryLoc) return handle(\\"end\\");
+ if (entry.tryLoc <= this.prev) {
+ var hasCatch = hasOwn.call(entry, \\"catchLoc\\"), hasFinally = hasOwn.call(entry, \\"finallyLoc\\");
+ if (hasCatch && hasFinally) {
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
+ } else if (hasCatch) {
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
+ } else {
+ if (!hasFinally) throw new Error(\\"try statement without catch or finally\\");
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
+ }
+ }
+ }
+ },
+ abrupt: function abrupt(type, arg) {
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i];
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, \\"finallyLoc\\") && this.prev < entry.finallyLoc) {
+ var finallyEntry = entry;
+ break;
+ }
+ }
+ finallyEntry && (\\"break\\" === type || \\"continue\\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
+ var record = finallyEntry ? finallyEntry.completion : {};
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = \\"next\\",
+ this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
+ },
+ complete: function complete(record, afterLoc) {
+ if (\\"throw\\" === record.type) throw record.arg;
+ return \\"break\\" === record.type || \\"continue\\" === record.type ? this.next = record.arg : \\"return\\" === record.type ? (this.rval = this.arg = record.arg,
+ this.method = \\"return\\", this.next = \\"end\\") : \\"normal\\" === record.type && afterLoc && (this.next = afterLoc),
+ ContinueSentinel;
+ },
+ finish: function finish(finallyLoc) {
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i];
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc),
+ resetTryEntry(entry), ContinueSentinel;
+ }
+ },
+ catch: function _catch(tryLoc) {
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i];
+ if (entry.tryLoc === tryLoc) {
+ var record = entry.completion;
+ if (\\"throw\\" === record.type) {
+ var thrown = record.arg;
+ resetTryEntry(entry);
+ }
+ return thrown;
+ }
+ }
+ throw new Error(\\"illegal catch attempt\\");
+ },
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
+ return this.delegate = {
+ iterator: values(iterable),
+ resultName: resultName,
+ nextLoc: nextLoc
+ }, \\"next\\" === this.method && (this.arg = undefined), ContinueSentinel;
+ }
+ }, exports;
+ }
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
+ try {
+ var info = gen[key](arg);
+ var value = info.value;
+ } catch (error) {
+ reject(error);
+ return;
+ }
+ if (info.done) {
+ resolve(value);
+ } else {
+ Promise.resolve(value).then(_next, _throw);
+ }
+ }
+ function _asyncToGenerator(fn) {
+ return function() {
+ var self = this, args = arguments;
+ return new Promise((function(resolve, reject) {
+ var gen = fn.apply(self, args);
+ function _next(value) {
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, \\"next\\", value);
+ }
+ function _throw(err) {
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, \\"throw\\", err);
+ }
+ _next(undefined);
+ }));
+ };
+ }
+ var classCallCheck = __webpack_require__(3);
+ var createClass = __webpack_require__(4);
+ var inherits = __webpack_require__(6);
+ var createSuper = __webpack_require__(5);
+ var react = __webpack_require__(0);
+ var taro_components = __webpack_require__(1);
+ var index = __webpack_require__(17);
+ var index_Index = function(_Component) {
+ Object(inherits[\\"a\\"])(Index, _Component);
+ var _super = Object(createSuper[\\"a\\"])(Index);
+ function Index() {
+ Object(classCallCheck[\\"a\\"])(this, Index);
+ return _super.apply(this, arguments);
+ }
+ Object(createClass[\\"a\\"])(Index, [ {
+ key: \\"componentWillMount\\",
+ value: function() {
+ var _componentWillMount = _asyncToGenerator(_regeneratorRuntime().mark((function _callee() {
+ return _regeneratorRuntime().wrap((function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ _context.next = 2;
+ return Promise.resolve(1);
+
+ case 2:
+ case \\"end\\":
+ return _context.stop();
+ }
+ }
+ }), _callee);
+ })));
+ function componentWillMount() {
+ return _componentWillMount.apply(this, arguments);
+ }
+ return componentWillMount;
+ }()
+ }, {
+ key: \\"componentDidMount\\",
+ value: function componentDidMount() {}
+ }, {
+ key: \\"componentWillUnmount\\",
+ value: function componentWillUnmount() {}
+ }, {
+ key: \\"componentDidShow\\",
+ value: function componentDidShow() {}
+ }, {
+ key: \\"componentDidHide\\",
+ value: function componentDidHide() {}
+ }, {
+ key: \\"render\\",
+ value: function render() {
+ return react[\\"default\\"].createElement(taro_components[\\"View\\"], {
+ className: \\"index\\"
+ }, react[\\"default\\"].createElement(taro_components[\\"Text\\"], null, \\"Hello world!\\"), react[\\"default\\"].createElement(taro_components[\\"Input\\"], {
+ placeholder: \\"input\\",
+ value: \\"\\"
+ }), react[\\"default\\"].createElement(taro_components[\\"Textarea\\"], {
+ value: \\"\\"
+ }), react[\\"default\\"].createElement(taro_components[\\"Swiper\\"], null, react[\\"default\\"].createElement(taro_components[\\"SwiperItem\\"], null, react[\\"default\\"].createElement(taro_components[\\"Text\\"], null, \\"Swiper item\\"))), react[\\"default\\"].createElement(taro_components[\\"Video\\"], null), react[\\"default\\"].createElement(taro_components[\\"Canvas\\"], null, react[\\"default\\"].createElement(taro_components[\\"CoverView\\"], null, react[\\"default\\"].createElement(taro_components[\\"CoverImage\\"], null))));
+ }
+ } ]);
+ return Index;
+ }(react[\\"Component\\"]);
+ var config = {
+ navigationBarTitleText: \\"\\\\u9996\\\\u9875\\"
+ };
+ var inst = Page(Object(taro_runtime[\\"createPageConfig\\"])(index_Index, \\"pages/index/index\\", {
+ root: {
+ cn: []
+ }
+ }, config || {}));
+ }
+}, [ [ 22, 0, 1, 3, 2 ] ] ]);
+
+/** filePath: dist/pages/index/index.js.LICENSE.txt **/
+/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
+
+
+/** filePath: dist/pages/index/index.json **/
+{\\"navigationBarTitleText\\":\\"首页\\",\\"usingComponents\\":{\\"comp\\":\\"../../comp\\"}}
+
+/** filePath: dist/pages/index/index.wxml **/
+
+
+
+/** filePath: dist/pages/index/index.wxss **/
+
+
+/** filePath: dist/runtime.js **/
+
+
+/** filePath: dist/taro.js **/
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 1 ], {
+ 1: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ var _unused_webpack_default_export = \\"taro-components-mock\\";
+ },
+ 2: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ var _unused_webpack_default_export = \\"taro-runtime-mock\\";
+ },
+ 9: function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_exports__[\\"a\\"] = \\"taro-react-mock\\";
+ }
+} ]);
+
+/** filePath: dist/utils.wxs **/
+module.exports = {
+ a: function (l, n, s) {
+ var a = [\\"7\\",\\"0\\",\\"18\\",\\"5\\",\\"2\\",\\"11\\",\\"6\\",\\"4\\",\\"38\\",\\"39\\",\\"22\\",\\"19\\",\\"36\\",\\"40\\",\\"41\\"]
+ var b = [\\"4\\",\\"38\\",\\"39\\",\\"22\\",\\"19\\",\\"36\\",\\"40\\",\\"41\\"]
+ if (a.indexOf(n) === -1) {
+ l = 0
+ }
+ if (b.indexOf(n) > -1) {
+ var u = s.split(',')
+ var depth = 0
+ for (var i = 0; i < u.length; i++) {
+ if (u[i] === n) depth++
+ }
+ l = depth
+ }
+ return 'tmpl_' + l + '_' + n
+ },
+ b: function (a, b) {
+ return a === undefined ? b : a
+ },
+ c: function(i, prefix) {
+ var s = i.focus !== undefined ? 'focus' : 'blur'
+ return prefix + i.nn + '_' + s
+ },
+ d: function (i, v) {
+ return i === undefined ? v : i
+ },
+ e: function (n) {
+ return 'tmpl_' + n + '_container'
+ },
+ f: function (l, n) {
+ var b = [\\"4\\",\\"38\\",\\"39\\",\\"22\\",\\"19\\",\\"36\\",\\"40\\",\\"41\\"]
+ if (b.indexOf(n) > -1) {
+ if (l) l += ','
+ l += n
+ }
+ return l
+ }
+}
+
+/** filePath: dist/vendors.js **/
+(wx[\\"webpackJsonp\\"] = wx[\\"webpackJsonp\\"] || []).push([ [ 3 ], [ , , , function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.d(__webpack_exports__, \\"a\\", (function() {
+ return _classCallCheck;
+ }));
+ function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError(\\"Cannot call a class as a function\\");
+ }
+ }
+}, function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.d(__webpack_exports__, \\"a\\", (function() {
+ return _createClass;
+ }));
+ function _defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];
+ descriptor.enumerable = descriptor.enumerable || false;
+ descriptor.configurable = true;
+ if (\\"value\\" in descriptor) descriptor.writable = true;
+ Object.defineProperty(target, descriptor.key, descriptor);
+ }
+ }
+ function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ Object.defineProperty(Constructor, \\"prototype\\", {
+ writable: false
+ });
+ return Constructor;
+ }
+}, function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.d(__webpack_exports__, \\"a\\", (function() {
+ return _createSuper;
+ }));
+ function _getPrototypeOf(o) {
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
+ return o.__proto__ || Object.getPrototypeOf(o);
+ };
+ return _getPrototypeOf(o);
+ }
+ function _isNativeReflectConstruct() {
+ if (typeof Reflect === \\"undefined\\" || !Reflect.construct) return false;
+ if (Reflect.construct.sham) return false;
+ if (typeof Proxy === \\"function\\") return true;
+ try {
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {})));
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+ var esm_typeof = __webpack_require__(7);
+ function _assertThisInitialized(self) {
+ if (self === void 0) {
+ throw new ReferenceError(\\"this hasn't been initialised - super() hasn't been called\\");
+ }
+ return self;
+ }
+ function _possibleConstructorReturn(self, call) {
+ if (call && (Object(esm_typeof[\\"a\\"])(call) === \\"object\\" || typeof call === \\"function\\")) {
+ return call;
+ } else if (call !== void 0) {
+ throw new TypeError(\\"Derived constructors may only return object or undefined\\");
+ }
+ return _assertThisInitialized(self);
+ }
+ function _createSuper(Derived) {
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
+ return function _createSuperInternal() {
+ var Super = _getPrototypeOf(Derived), result;
+ if (hasNativeReflectConstruct) {
+ var NewTarget = _getPrototypeOf(this).constructor;
+ result = Reflect.construct(Super, arguments, NewTarget);
+ } else {
+ result = Super.apply(this, arguments);
+ }
+ return _possibleConstructorReturn(this, result);
+ };
+ }
+}, function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.d(__webpack_exports__, \\"a\\", (function() {
+ return _inherits;
+ }));
+ function _setPrototypeOf(o, p) {
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
+ o.__proto__ = p;
+ return o;
+ };
+ return _setPrototypeOf(o, p);
+ }
+ function _inherits(subClass, superClass) {
+ if (typeof superClass !== \\"function\\" && superClass !== null) {
+ throw new TypeError(\\"Super expression must either be null or a function\\");
+ }
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
+ constructor: {
+ value: subClass,
+ writable: true,
+ configurable: true
+ }
+ });
+ Object.defineProperty(subClass, \\"prototype\\", {
+ writable: false
+ });
+ if (superClass) _setPrototypeOf(subClass, superClass);
+ }
+}, function(module, __webpack_exports__, __webpack_require__) {
+ \\"use strict\\";
+ __webpack_require__.d(__webpack_exports__, \\"a\\", (function() {
+ return _typeof;
+ }));
+ function _typeof(obj) {
+ \\"@babel/helpers - typeof\\";
+ return _typeof = \\"function\\" == typeof Symbol && \\"symbol\\" == typeof Symbol.iterator ? function(obj) {
+ return typeof obj;
+ } : function(obj) {
+ return obj && \\"function\\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \\"symbol\\" : typeof obj;
+ }, _typeof(obj);
+ }
+} ] ]);
+"
+`;
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/babel.config.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/babel.config.js
new file mode 100644
index 000000000000..a0c7c142d472
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/babel.config.js
@@ -0,0 +1,11 @@
+// babel-preset-taro 更多选项和默认值:
+// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
+module.exports = {
+ presets: [
+ ['taro', {
+ framework: 'react',
+ ts: false,
+ reactJsxRuntime: 'classic'
+ }]
+ ]
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.config.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.config.js
new file mode 100644
index 000000000000..17a7fcfb7cf1
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.config.js
@@ -0,0 +1,29 @@
+export default {
+ pages: ['pages/index/index'],
+ window: {
+ backgroundTextStyle: 'light',
+ navigationBarBackgroundColor: '#fff',
+ navigationBarTitleText: 'WeChat',
+ navigationBarTextStyle: 'black',
+ },
+ plugins: {
+ testPlugin: {
+ version: 'dev',
+ provider: 'xxx',
+ export: 'index',
+ },
+ },
+ subpackages: [
+ {
+ root: 'packageA',
+ pages: ['detail/index', 'my/index'],
+ plugins: {
+ testSubPackagePlugin: {
+ version: 'dev',
+ provider: 'xxx',
+ export: 'index',
+ },
+ },
+ },
+ ],
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.css b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.css
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.js
new file mode 100644
index 000000000000..f1011d4d3ea5
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/app.js
@@ -0,0 +1,18 @@
+import React, { Component } from 'react'
+import './app.css'
+
+class App extends Component {
+
+ componentDidMount () {}
+
+ componentDidShow () {}
+
+ componentDidHide () {}
+
+ // this.props.children 是将要会渲染的页面
+ render () {
+ return this.props.children
+ }
+}
+
+export default App
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/index.html b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/index.html
new file mode 100644
index 000000000000..826f423513e9
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/index.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/index.js
new file mode 100644
index 000000000000..a38ac435e877
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/index.js
@@ -0,0 +1,3 @@
+export function hello() {
+ console.log('hello from mini')
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/common.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/common.js
new file mode 100644
index 000000000000..4a3d864ec6d8
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/common.js
@@ -0,0 +1,3 @@
+export function someCommon (text) {
+ console.log('log something: ', text)
+}
\ No newline at end of file
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.config.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.config.js
new file mode 100644
index 000000000000..f0ac61c7350c
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.config.js
@@ -0,0 +1,3 @@
+export default {
+ navigationBarTitleText: '详情页'
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.css b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.css
new file mode 100644
index 000000000000..2c6cac758b66
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.css
@@ -0,0 +1,4 @@
+.detail {
+ width: 100%;
+ height: 100%;
+}
\ No newline at end of file
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.jsx b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.jsx
new file mode 100644
index 000000000000..be6682e56524
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/detail/index.jsx
@@ -0,0 +1,18 @@
+import React, { Component } from 'react'
+import { View, Text } from '@tarojs/components'
+import { someCommon } from '../common'
+import './index.css'
+
+export default class Detail extends Component {
+ componentDidMount () {
+ someCommon('detail')
+ }
+
+ render () {
+ return (
+
+ I m detail
+
+ )
+ }
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/index.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/index.js
new file mode 100644
index 000000000000..9b4c244c59e5
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/index.js
@@ -0,0 +1,3 @@
+export function hello() {
+ console.log('hello from mini sub package')
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/my/index.config.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/my/index.config.js
new file mode 100644
index 000000000000..87a55cb956ee
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/my/index.config.js
@@ -0,0 +1,3 @@
+export default {
+ navigationBarTitleText: '个人中心页'
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/my/index.jsx b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/my/index.jsx
new file mode 100644
index 000000000000..74ffb47bed3f
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/packageA/my/index.jsx
@@ -0,0 +1,17 @@
+import React, { Component } from 'react'
+import { View, Text } from '@tarojs/components'
+import { someCommon } from '../common'
+
+export default class My extends Component {
+ componentDidMount () {
+ someCommon('my')
+ }
+
+ render () {
+ return (
+
+ I m my
+
+ )
+ }
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.config.js b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.config.js
new file mode 100644
index 000000000000..be3ab0085ba7
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.config.js
@@ -0,0 +1,3 @@
+export default {
+ navigationBarTitleText: '首页'
+}
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.css b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.css
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.jsx b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.jsx
new file mode 100644
index 000000000000..7bd0cce73e27
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/fixtures/plugin-export/src/pages/index/index.jsx
@@ -0,0 +1,42 @@
+import React, { Component } from 'react'
+import { View, Text, Input, Textarea, Swiper, SwiperItem, Canvas, Video, CoverImage, CoverView } from '@tarojs/components'
+import './index.css'
+
+export default class Index extends Component {
+
+ async componentWillMount () {
+ await Promise.resolve(1)
+ }
+
+ componentDidMount () { }
+
+ componentWillUnmount () { }
+
+ componentDidShow () { }
+
+ componentDidHide () { }
+
+ render () {
+ return (
+
+ Hello world!
+
+
+
+
+
+ Swiper item
+
+
+
+
+
+
+
+ )
+ }
+}
diff --git a/packages/taro-mini-runner/src/__tests__/plugin-export.spec.ts b/packages/taro-mini-runner/src/__tests__/plugin-export.spec.ts
new file mode 100644
index 000000000000..923f6b22f7b9
--- /dev/null
+++ b/packages/taro-mini-runner/src/__tests__/plugin-export.spec.ts
@@ -0,0 +1,15 @@
+import { compile, getOutput } from './utils/compiler'
+
+describe('plugin-export', () => {
+ test('should build plugin export files', async () => {
+ const { stats, config } = await compile('plugin-export')
+ const assets = stats.toJson().assets || []
+
+ expect(assets.length).toMatchSnapshot()
+
+ const output = getOutput(stats, config)
+ expect(output.includes('dist/index.js')).toBe(true)
+ expect(output.includes('dist/packageA/index.js')).toBe(true)
+ expect(output).toMatchSnapshot()
+ })
+})
diff --git a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts
index d8e89120ff8c..c6a37dc45c1b 100644
--- a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts
+++ b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts
@@ -133,6 +133,7 @@ export default class TaroMiniPlugin {
themeLocation: string
pageLoaderName = '@tarojs/taro-loader/lib/page'
independentPackages = new Map()
+ pluginExportEntries = new Map()
constructor (options = {} as ITaroMiniPluginOptions) {
this.options = Object.assign({
@@ -395,6 +396,7 @@ export default class TaroMiniPlugin {
this.getConfigFiles(compiler)
} else {
this.appConfig = this.getAppConfig()
+ this.getAppPluginEntries()
this.getPages()
this.getPagesConfig()
this.getDarkMode()
@@ -529,6 +531,21 @@ export default class TaroMiniPlugin {
return appConfig as AppConfig
}
+ /**
+ * 获取 app 中的插件导出
+ */
+ getAppPluginEntries () {
+ const { plugins = {} } = this.appConfig
+ // 查找 app 的插件导出
+ Object.values(plugins).forEach((plugin) => {
+ if (plugin.export) {
+ const filePath = path.join(this.options.sourceDir, plugin.export)
+ const fileName = path.basename(filePath).replace(path.extname(filePath), '')
+ this.pluginExportEntries.set(fileName, filePath)
+ }
+ })
+ }
+
/**
* 根据 app config 的 pages 配置项,收集所有页面信息,
* 包括处理分包和 tabbar
@@ -654,6 +671,9 @@ export default class TaroMiniPlugin {
this.addEntry(item.path, item.name, META_TYPE.COMPONENT)
}
})
+ this.pluginExportEntries.forEach((filePath, entryName) => {
+ this.addEntry(filePath, entryName, META_TYPE.EXPORTS)
+ })
}
replaceExt (file: string, ext: string) {
@@ -727,8 +747,8 @@ export default class TaroMiniPlugin {
const { frameworkExts } = this.options
if (subPackages && subPackages.length) {
subPackages.forEach(item => {
+ const root = item.root
if (item.pages && item.pages.length) {
- const root = item.root
const isIndependent = !!item.independent
if (isIndependent) {
this.independentPackages.set(root, [])
@@ -760,6 +780,16 @@ export default class TaroMiniPlugin {
}
})
}
+ // 处理子包中的插件导出
+ if (item.plugins) {
+ Object.values(item.plugins).forEach((plugin) => {
+ if (plugin.export) {
+ const filePath = path.join(this.options.sourceDir, root, plugin.export)
+ const fileName = path.basename(filePath).replace(path.extname(filePath), '')
+ this.pluginExportEntries.set(`${root}/${fileName}`, filePath)
+ }
+ })
+ }
})
}
}
diff --git a/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts b/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts
index 1f21828898dd..412f23af607b 100644
--- a/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts
+++ b/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts
@@ -109,6 +109,7 @@ export default class TaroMiniPlugin {
themeLocation: string
pageLoaderName = '@tarojs/taro-loader/lib/page'
independentPackages = new Map()
+ pluginExportEntries = new Map()
constructor (options = {} as ITaroMiniPluginOptions) {
this.options = Object.assign({
@@ -356,6 +357,7 @@ export default class TaroMiniPlugin {
this.getConfigFiles(compiler)
} else {
this.appConfig = this.getAppConfig()
+ this.getAppPluginEntries()
this.getPages()
this.getPagesConfig()
this.getDarkMode()
@@ -494,6 +496,21 @@ export default class TaroMiniPlugin {
return appConfig as AppConfig
}
+ /**
+ * 获取 app 中的插件导出
+ */
+ getAppPluginEntries () {
+ const { plugins = {} } = this.appConfig
+ // 查找 app 的插件导出
+ Object.values(plugins).forEach((plugin) => {
+ if (plugin.export) {
+ const filePath = path.join(this.options.sourceDir, plugin.export)
+ const fileName = path.basename(filePath).replace(path.extname(filePath), '')
+ this.pluginExportEntries.set(fileName, filePath)
+ }
+ })
+ }
+
/**
* 根据 app config 的 pages 配置项,收集所有页面信息,
* 包括处理分包和 tabbar
@@ -621,6 +638,9 @@ export default class TaroMiniPlugin {
this.addEntry(item.path, item.name, META_TYPE.COMPONENT)
}
})
+ this.pluginExportEntries.forEach((filePath, entryName) => {
+ this.addEntry(filePath, entryName, META_TYPE.EXPORTS)
+ })
}
replaceExt (file: string, ext: string) {
@@ -691,8 +711,8 @@ export default class TaroMiniPlugin {
const { frameworkExts } = this.options
if (subPackages && subPackages.length) {
subPackages.forEach(item => {
+ const root = item.root
if (item.pages && item.pages.length) {
- const root = item.root
const isIndependent = !!item.independent
if (isIndependent) {
this.independentPackages.set(root, [])
@@ -724,6 +744,16 @@ export default class TaroMiniPlugin {
}
})
}
+ // 处理子包中的插件导出
+ if (item.plugins) {
+ Object.values(item.plugins).forEach((plugin) => {
+ if (plugin.export) {
+ const filePath = path.join(this.options.sourceDir, root, plugin.export)
+ const fileName = path.basename(filePath).replace(path.extname(filePath), '')
+ this.pluginExportEntries.set(`${root}/${fileName}`, filePath)
+ }
+ })
+ }
})
}
}
diff --git a/packages/taro/types/taro.config.d.ts b/packages/taro/types/taro.config.d.ts
index b484113e2ace..8e127f43af8d 100644
--- a/packages/taro/types/taro.config.d.ts
+++ b/packages/taro/types/taro.config.d.ts
@@ -182,6 +182,7 @@ declare module './index' {
[key: string]: {
version: string
provider: string
+ export?: string
}
}
@@ -283,7 +284,16 @@ declare module './index' {
* - chooseAddress: 获取用户地址信息
* @see https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#requiredPrivateInfos
*/
- requiredPrivateInfos?: ('getFuzzyLocation' | 'getLocation' | 'onLocationChange' | 'startLocationUpdate' | 'startLocationUpdateBackground' | 'chooseLocation' | 'choosePoi' | 'chooseAddress')[]
+ requiredPrivateInfos?: (
+ | 'getFuzzyLocation'
+ | 'getLocation'
+ | 'onLocationChange'
+ | 'startLocationUpdate'
+ | 'startLocationUpdateBackground'
+ | 'chooseLocation'
+ | 'choosePoi'
+ | 'chooseAddress'
+ )[]
/** 使用到的插件
* @since 1.9.6
*/
@@ -378,14 +388,16 @@ declare module './index' {
enableFPSPanel?: boolean
}
/** touch 事件监听是否为 passive,默认false */
- enablePassiveEvent?: boolean | {
- /** 是否设置 touchstart 事件为 passive,默认false */
- touchstart?: boolean
- /** 是否设置 touchmove 事件为 passive,默认false */
- touchmove?: boolean
- /** 是否设置 wheel 事件为 passive,默认false */
- wheel?: boolean
- }
+ enablePassiveEvent?:
+ | boolean
+ | {
+ /** 是否设置 touchstart 事件为 passive,默认false */
+ touchstart?: boolean
+ /** 是否设置 touchmove 事件为 passive,默认false */
+ touchmove?: boolean
+ /** 是否设置 wheel 事件为 passive,默认false */
+ wheel?: boolean
+ }
/** 自定义模块映射规则 */
resolveAlias?: Record
/** 接受一个数组,每一项都是字符串,来指定编译为原生小程序组件的组件入口 */
@@ -422,4 +434,3 @@ declare module './index' {
Config: Config
}
}
-