UNPKG

asma-qiankun-plugin-vite

Version:

vite for qiankun with some adjustments for hmr

38 lines (34 loc) 1.52 kB
/*! * asma-qiankun-plugin-vite.js v0.2.3 * (c) 2022-2023 IE * Released under the MIT License. * Inspired by vite-plugin-qiankun (https://github.com/tengmaoqing/vite-plugin-qiankun). */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); /* eslint-disable camelcase */ // reactRefresh // implement hot update // eslint-disable-next-line @typescript-eslint/no-empty-function window.$RefreshReg$ = () => { }; window.$RefreshSig$ = () => (type) => type; window.__vite_plugin_react_preamble_installed__ = true; function generateQiankunHelpers(appName) { var _a; const qiankunWindow = typeof window !== 'undefined' ? ((_a = window.__GLOBAL_CONCURRENT_QIANKUN__) === null || _a === void 0 ? void 0 : _a[appName]) || window.proxy || window : {}; const renderWithQiankun = (qiankunLifeCycle) => { // The function has only one chance to execute, and the life cycle needs to be assigned to the global if (qiankunWindow === null || qiankunWindow === void 0 ? void 0 : qiankunWindow.__POWERED_BY_QIANKUN__) { if (!window.moduleQiankunAppLifeCycles) { window.moduleQiankunAppLifeCycles = {}; } if (`qiankunName` in qiankunWindow && qiankunWindow.qiankunName) { window.moduleQiankunAppLifeCycles[appName] = qiankunLifeCycle; } } }; return { renderWithQiankun, qiankunWindow, }; } exports.generateQiankunHelpers = generateQiankunHelpers;