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 **/ + +