提交 81329b2e 编写于 作者: fxy060608's avatar fxy060608

wip(mp): render

上级 9d004089
(function (window, factory) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : window || self, factory(window.Tools = {}));
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Tools = {}));
})(this, (function (exports) { 'use strict';
const ACTION_TYPE_PAGE_CREATE = 1;
......
......@@ -1501,9 +1501,9 @@ var serviceContext = (function (vue) {
if (typeof uni !== 'undefined' && uni.getLocale) {
return uni.getLocale();
}
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 window 上挂了 getLocale
if (typeof window !== 'undefined' && window.getLocale) {
return window.getLocale();
// 小程序平台,uni 和 uni-i18n 互相引用,导致访问不到 uni,故在 global 上挂了 getLocale
if (typeof global !== 'undefined' && global.getLocale) {
return global.getLocale();
}
return LOCALE_EN;
}
......@@ -11996,7 +11996,7 @@ var serviceContext = (function (vue) {
plus = newPlus;
restoreOldSetStatusBarStyle(plus.navigator.setStatusBarStyle);
plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
/* eslint-disable no-window-assign */
/* eslint-disable no-global-assign */
// @ts-ignore
setTimeout = newSetTimeout;
// @ts-ignore
......@@ -13238,7 +13238,7 @@ var serviceContext = (function (vue) {
// do check in _tr_init()
//if (static_init_done) return;
/* For some embedded targets, window variables are not initialized: */
/* For some embedded targets, global variables are not initialized: */
/*#ifdef NO_INIT_GLOBAL_POINTERS
static_l_desc.static_tree = static_ltree;
static_l_desc.extra_bits = extra_lbits;
......
......@@ -895,7 +895,7 @@ export default function vueFactory(exports) {
var _globalThis;
var getGlobalThis = () => {
return _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof window !== 'undefined' ? window : {});
return _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {});
};
function warn(msg, ...args) {
......@@ -2315,7 +2315,7 @@ export default function vueFactory(exports) {
var isHmrUpdating = false;
var hmrDirtyComponents = new Set(); // Expose the HMR runtime on the window object
var hmrDirtyComponents = new Set(); // Expose the HMR runtime on the global object
// This makes it entirely tree-shakable without polluting the exports and makes
// it easier to be used in toolings like vue-loader
// Note: for a component to be eligible for HMR it also needs the __hmrId option
......@@ -8669,7 +8669,7 @@ export default function vueFactory(exports) {
var res = // local registration
// check instance[type] first which is resolved for options API
resolve(instance[type] || Component[type], name) || // window registration
resolve(instance[type] || Component[type], name) || // global registration
resolve(instance.appContext[type], name);
if (!res && maybeSelfReference) {
......@@ -9528,7 +9528,7 @@ export default function vueFactory(exports) {
/* CONTEXT */
;
return ctx[key];
} else if ( // window properties
} else if ( // global properties
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
{
return globalProperties[key];
......
......@@ -874,7 +874,7 @@ export default function vueFactory(exports) {
var _globalThis;
var getGlobalThis = () => {
return _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof window !== 'undefined' ? window : {});
return _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {});
};
var activeEffectScope;
......@@ -7495,7 +7495,7 @@ export default function vueFactory(exports) {
var res = // local registration
// check instance[type] first which is resolved for options API
resolve(instance[type] || Component[type], name) || // window registration
resolve(instance[type] || Component[type], name) || // global registration
resolve(instance.appContext[type], name);
if (!res && maybeSelfReference) {
......@@ -8268,7 +8268,7 @@ export default function vueFactory(exports) {
/* CONTEXT */
;
return ctx[key];
} else if ( // window properties
} else if ( // global properties
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
{
return globalProperties[key];
......
......@@ -326,8 +326,8 @@ const getGlobalThis = () => {
? self
: typeof window !== 'undefined'
? window
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {}));
};
......@@ -1449,7 +1449,7 @@ function computed(getterOrOptions, debugOptions) {
/* eslint-disable no-restricted-globals */
let isHmrUpdating = false;
const hmrDirtyComponents = new Set();
// Expose the HMR runtime on the window object
// Expose the HMR runtime on the global object
// This makes it entirely tree-shakable without polluting the exports and makes
// it easier to be used in toolings like vue-loader
// Note: for a component to be eligible for HMR it also needs the __hmrId option
......@@ -6686,7 +6686,7 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
// local registration
// check instance[type] first which is resolved for options API
resolve(instance[type] || Component[type], name) ||
// window registration
// global registration
resolve(instance.appContext[type], name);
if (!res && maybeSelfReference) {
// fallback to implicit self-reference
......@@ -7422,7 +7422,7 @@ const PublicInstanceProxyHandlers = {
return ctx[key];
}
else if (
// window properties
// global properties
((globalProperties = appContext.config.globalProperties),
hasOwn(globalProperties, key))) {
{
......
......@@ -16,7 +16,6 @@
]
},
"replacements": {
"global": "global",
"__GLOBAL__": "my",
"__PLATFORM__": "\"mp-alipay\"",
"__PLATFORM_TITLE__": "支付宝小程序"
......
......@@ -1435,7 +1435,7 @@ function createComponent$1(vueOptions) {
const createApp = initCreateApp(parseAppOptions);
my.EventChannel = EventChannel;
my.createApp = createApp;
my.createApp = global.createApp = createApp;
my.createPage = createPage;
my.createComponent = createComponent;
......
......@@ -9,6 +9,6 @@ export { createComponent } from './createComponent'
export const createApp = initCreateApp(parseAppOptions)
;(my as any).EventChannel = EventChannel
;(my as any).createApp = createApp
;(my as any).createApp = (global as any).createApp = createApp
;(my as any).createPage = createPage
;(my as any).createComponent = createComponent
......@@ -16,7 +16,6 @@
]
},
"replacements": {
"global": "global",
"__GLOBAL__": "swan",
"__PLATFORM__": "\"mp-baidu\"",
"__PLATFORM_TITLE__": "百度小程序"
......
......@@ -1396,7 +1396,7 @@ const createApp = initCreateApp(parseAppOptions);
const createPage = initCreatePage(parsePageOptions);
const createComponent = initCreateComponent(parseComponentOptions);
swan.EventChannel = EventChannel;
swan.createApp = createApp;
swan.createApp = global.createApp = createApp;
swan.createPage = createPage;
swan.createComponent = createComponent;
......
......@@ -15,6 +15,6 @@ export const createApp = initCreateApp(parseAppOptions)
export const createPage = initCreatePage(parsePageOptions)
export const createComponent = initCreateComponent(parseComponentOptions)
;(swan as any).EventChannel = EventChannel
;(swan as any).createApp = createApp
;(swan as any).createApp = (global as any).createApp = createApp
;(swan as any).createPage = createPage
;(swan as any).createComponent = createComponent
......@@ -16,7 +16,6 @@
]
},
"replacements": {
"global": "global",
"__GLOBAL__": "ks",
"__PLATFORM__": "\"mp-kuaishou\"",
"__PLATFORM_TITLE__": "快手小程序"
......
......@@ -1232,7 +1232,7 @@ var baseParseOptions = /*#__PURE__*/Object.freeze({
const createApp = initCreateApp();
const createPage = initCreatePage(baseParseOptions);
const createComponent$1 = initCreateComponent(baseParseOptions);
wx.createApp = createApp;
wx.createApp = global.createApp = createApp;
wx.createPage = createPage;
wx.createComponent = createComponent$1;
......@@ -1295,7 +1295,7 @@ var parseComponentOptions = extend({}, baseParseOptions, {
const createComponent = initCreateComponent(parseComponentOptions);
ks.EventChannel = EventChannel;
ks.createApp = createApp;
ks.createApp = global.createApp = createApp;
ks.createPage = createPage;
ks.createComponent = createComponent;
......
......@@ -7,6 +7,6 @@ import parseComponentOptions from './parseComponentOptions'
export { createApp, createPage } from '@dcloudio/uni-mp-weixin/src/runtime'
export const createComponent = initCreateComponent(parseComponentOptions)
;(ks as any).EventChannel = EventChannel
;(ks as any).createApp = createApp
;(ks as any).createApp = (global as any).createApp = createApp
;(ks as any).createPage = createPage
;(ks as any).createComponent = createComponent
......@@ -16,7 +16,6 @@
]
},
"replacements": {
"global": "global",
"__GLOBAL__": "qq",
"__PLATFORM__": "\"mp-qq\"",
"__PLATFORM_TITLE__": "QQ小程序"
......
......@@ -1232,12 +1232,12 @@ var parseOptions = /*#__PURE__*/Object.freeze({
const createApp = initCreateApp();
const createPage = initCreatePage(parseOptions);
const createComponent = initCreateComponent(parseOptions);
wx.createApp = createApp;
wx.createApp = global.createApp = createApp;
wx.createPage = createPage;
wx.createComponent = createComponent;
qq.EventChannel = EventChannel;
qq.createApp = createApp;
qq.createApp = global.createApp = createApp;
qq.createPage = createPage;
qq.createComponent = createComponent;
......
......@@ -7,6 +7,6 @@ import {
export * from '@dcloudio/uni-mp-weixin/src/runtime'
;(qq as any).EventChannel = EventChannel
;(qq as any).createApp = createApp
;(qq as any).createApp = (global as any).createApp = createApp
;(qq as any).createPage = createPage
;(qq as any).createComponent = createComponent
......@@ -16,7 +16,6 @@
]
},
"replacements": {
"global": "global",
"__GLOBAL__": "tt",
"__PLATFORM__": "\"mp-toutiao\"",
"__PLATFORM_TITLE__": "字节跳动小程序"
......
......@@ -1392,7 +1392,7 @@ const createApp = initCreateApp();
const createPage = initCreatePage(parsePageOptions);
const createComponent = initCreateComponent(parseComponentOptions);
tt.EventChannel = EventChannel;
tt.createApp = createApp;
tt.createApp = global.createApp = createApp;
tt.createPage = createPage;
tt.createComponent = createComponent;
......
......@@ -14,6 +14,6 @@ export const createApp = initCreateApp()
export const createPage = initCreatePage(parsePageOptions)
export const createComponent = initCreateComponent(parseComponentOptions)
;(tt as any).EventChannel = EventChannel
;(tt as any).createApp = createApp
;(tt as any).createApp = (global as any).createApp = createApp
;(tt as any).createPage = createPage
;(tt as any).createComponent = createComponent
......@@ -5,7 +5,7 @@ import { uniPagesJsonPlugin } from './plugins/pagesJson'
import { uniVirtualPlugin } from './plugins/virtual'
export default (options: UniMiniProgramPluginOptions) => {
return [
uniMainJsPlugin(),
uniMainJsPlugin(options),
uniManifestJsonPlugin(),
uniPagesJsonPlugin(),
uniVirtualPlugin(options),
......
import { defineUniMainJsPlugin } from '@dcloudio/uni-cli-shared'
import { UniMiniProgramPluginOptions } from '../plugin'
export function uniMainJsPlugin() {
export function uniMainJsPlugin(options: UniMiniProgramPluginOptions) {
return defineUniMainJsPlugin((opts) => {
return {
name: 'vite:uni-mp-main-js',
......@@ -23,15 +24,9 @@ export function uniMainJsPlugin() {
}
function createApp(code: string) {
return `${code.replace(
'createSSRApp',
'createVueApp as createSSRApp'
)};const __app__=createApp().app;__app__._component.mpType='app';__app__._component.render=()=>{};__app__.use(uni.__vuePlugin).mount("#app");`
return `${code};createApp().app.mount("#app");`
}
function createLegacyApp(code: string) {
return `function createApp(rootComponent,rootProps){rootComponent.mpTye='app';const app=createVueApp(rootComponent,rootProps).use(uni.__vuePlugin);app.render=()=>{};const oldMount=app.mount;app.mount=(container)=>{const appVm=oldMount.call(app,container);return appVm;};return app;};${code.replace(
'createApp',
'createVueApp'
)}`
return code
}
......@@ -2561,7 +2561,7 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
// local registration
// check instance[type] first which is resolved for options API
resolve(instance[type] || Component[type], name) ||
// window registration
// global registration
resolve(instance.appContext[type], name);
if (!res && maybeSelfReference) {
// fallback to implicit self-reference
......@@ -3048,7 +3048,7 @@ const PublicInstanceProxyHandlers = {
return ctx[key];
}
else if (
// window properties
// global properties
((globalProperties = appContext.config.globalProperties),
hasOwn(globalProperties, key))) {
{
......@@ -3392,6 +3392,11 @@ let compile;
const isRuntimeOnly = () => !compile;
function finishComponentSetup(instance, isSSR, skipOptions) {
const Component = instance.type;
// template / render function normalization
// could be already set when returned from setup()
if (!instance.render) {
instance.render = (Component.render || NOOP);
}
// support for 2.x options
if (__VUE_OPTIONS_API__ && !(false )) {
setCurrentInstance(instance);
......@@ -4542,61 +4547,25 @@ function getMPInstanceData(instance, keys) {
});
return ret;
}
function getVueInstanceData(instance) {
const { data, setupState, ctx } = instance;
const keys = new Set();
const ret = Object.create(null);
Object.keys(setupState).forEach(key => {
keys.add(key);
ret[key] = setupState[key];
});
if (data) {
Object.keys(data).forEach(key => {
if (!keys.has(key)) {
keys.add(key);
ret[key] = data[key];
}
});
}
if (__VUE_OPTIONS_API__) {
if (ctx.$computedKeys) {
ctx.$computedKeys.forEach((key) => {
if (!keys.has(key)) {
keys.add(key);
ret[key] = ctx[key];
}
});
}
}
if (ctx.$mp) {
// TODO
extend(ret, ctx.$mp.data || {});
}
// TODO form-field
// track
return { keys, data: JSON.parse(JSON.stringify(ret)) };
}
function patch(instance) {
function patch(instance, data) {
const ctx = instance.ctx;
const mpType = ctx.mpType;
if (mpType === 'page' || mpType === 'component') {
const start = Date.now();
const mpInstance = ctx.$scope;
const { keys, data } = getVueInstanceData(instance);
const keys = Object.keys(data);
// data.__webviewId__ = mpInstance.data.__webviewId__
const diffData = diff(data, getMPInstanceData(mpInstance, keys));
if (Object.keys(diffData).length) {
if (process.env.VUE_APP_DEBUG) {
console.log('[' +
+new Date() +
'][' +
(mpInstance.is || mpInstance.route) +
'][' +
instance.uid +
'][耗时' +
(Date.now() - start) +
']差量更新', JSON.stringify(diffData));
}
console.log('[' +
+new Date() +
'][' +
(mpInstance.is || mpInstance.route) +
'][' +
instance.uid +
'][耗时' +
(Date.now() - start) +
']差量更新', JSON.stringify(diffData));
ctx.__next_tick_pending = true;
mpInstance.setData(diffData, () => {
ctx.__next_tick_pending = false;
......@@ -4670,11 +4639,48 @@ function mountComponent(initialVNode, options) {
}
return instance.proxy;
}
const getFunctionalFallthrough = (attrs) => {
let res;
for (const key in attrs) {
if (key === 'class' || key === 'style' || isOn(key)) {
(res || (res = {}))[key] = attrs[key];
}
}
return res;
};
function renderComponentRoot(instance) {
const { type: Component, vnode, proxy, withProxy, props, slots, attrs, emit, render, renderCache, data, setupState, ctx } = instance;
let result;
const prev = setCurrentRenderingInstance(instance);
try {
if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
// withProxy is a proxy with a different `has` trap only for
// runtime-compiled render functions using `with` block.
const proxyToUse = withProxy || proxy;
result = render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx);
}
else {
// functional
const render = Component;
result =
render.length > 1
? render(props, { attrs, slots, emit })
: render(props, null /* we know it doesn't need it */)
? attrs
: getFunctionalFallthrough(attrs);
}
}
catch (err) {
handleError(err, instance, 1 /* RENDER_FUNCTION */);
result = false;
}
setCurrentRenderingInstance(prev);
return result;
}
function setupRenderEffect(instance) {
const componentUpdateFn = () => {
if (!instance.isMounted) {
instance.render && instance.render.call(instance.proxy);
patch(instance);
patch(instance, renderComponentRoot(instance));
}
else {
instance.render && instance.render.call(instance.proxy);
......@@ -4686,7 +4692,7 @@ function setupRenderEffect(instance) {
invokeArrayFns(bu);
}
effect.allowRecurse = true;
patch(instance);
patch(instance, renderComponentRoot(instance));
// updated hook
if (u) {
queuePostRenderEffect$1(u);
......@@ -4928,8 +4934,7 @@ var plugin = {
const oldMount = app.mount;
app.mount = function mount(rootContainer) {
const instance = oldMount.call(app, rootContainer);
// @ts-ignore
createMiniProgramApp(instance);
global.createApp(instance);
return instance;
};
},
......
......@@ -3324,6 +3324,11 @@ let compile;
const isRuntimeOnly = () => !compile;
function finishComponentSetup(instance, isSSR, skipOptions) {
const Component = instance.type;
// template / render function normalization
// could be already set when returned from setup()
if (!instance.render) {
instance.render = (Component.render || NOOP);
}
// support for 2.x options
if (__VUE_OPTIONS_API__ && !(false )) {
setCurrentInstance(instance);
......@@ -4474,61 +4479,25 @@ function getMPInstanceData(instance, keys) {
});
return ret;
}
function getVueInstanceData(instance) {
const { data, setupState, ctx } = instance;
const keys = new Set();
const ret = Object.create(null);
Object.keys(setupState).forEach(key => {
keys.add(key);
ret[key] = setupState[key];
});
if (data) {
Object.keys(data).forEach(key => {
if (!keys.has(key)) {
keys.add(key);
ret[key] = data[key];
}
});
}
if (__VUE_OPTIONS_API__) {
if (ctx.$computedKeys) {
ctx.$computedKeys.forEach((key) => {
if (!keys.has(key)) {
keys.add(key);
ret[key] = ctx[key];
}
});
}
}
if (ctx.$mp) {
// TODO
extend(ret, ctx.$mp.data || {});
}
// TODO form-field
// track
return { keys, data: JSON.parse(JSON.stringify(ret)) };
}
function patch(instance) {
function patch(instance, data) {
const ctx = instance.ctx;
const mpType = ctx.mpType;
if (mpType === 'page' || mpType === 'component') {
const start = Date.now();
const mpInstance = ctx.$scope;
const { keys, data } = getVueInstanceData(instance);
const keys = Object.keys(data);
// data.__webviewId__ = mpInstance.data.__webviewId__
const diffData = diff(data, getMPInstanceData(mpInstance, keys));
if (Object.keys(diffData).length) {
if (process.env.VUE_APP_DEBUG) {
console.log('[' +
+new Date() +
'][' +
(mpInstance.is || mpInstance.route) +
'][' +
instance.uid +
'][耗时' +
(Date.now() - start) +
']差量更新', JSON.stringify(diffData));
}
console.log('[' +
+new Date() +
'][' +
(mpInstance.is || mpInstance.route) +
'][' +
instance.uid +
'][耗时' +
(Date.now() - start) +
']差量更新', JSON.stringify(diffData));
ctx.__next_tick_pending = true;
mpInstance.setData(diffData, () => {
ctx.__next_tick_pending = false;
......@@ -4602,11 +4571,48 @@ function mountComponent(initialVNode, options) {
}
return instance.proxy;
}
const getFunctionalFallthrough = (attrs) => {
let res;
for (const key in attrs) {
if (key === 'class' || key === 'style' || isOn(key)) {
(res || (res = {}))[key] = attrs[key];
}
}
return res;
};
function renderComponentRoot(instance) {
const { type: Component, vnode, proxy, withProxy, props, slots, attrs, emit, render, renderCache, data, setupState, ctx } = instance;
let result;
const prev = setCurrentRenderingInstance(instance);
try {
if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
// withProxy is a proxy with a different `has` trap only for
// runtime-compiled render functions using `with` block.
const proxyToUse = withProxy || proxy;
result = render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx);
}
else {
// functional
const render = Component;
result =
render.length > 1
? render(props, { attrs, slots, emit })
: render(props, null /* we know it doesn't need it */)
? attrs
: getFunctionalFallthrough(attrs);
}
}
catch (err) {
handleError(err, instance, 1 /* RENDER_FUNCTION */);
result = false;
}
setCurrentRenderingInstance(prev);
return result;
}
function setupRenderEffect(instance) {
const componentUpdateFn = () => {
if (!instance.isMounted) {
instance.render && instance.render.call(instance.proxy);
patch(instance);
patch(instance, renderComponentRoot(instance));
}
else {
instance.render && instance.render.call(instance.proxy);
......@@ -4618,7 +4624,7 @@ function setupRenderEffect(instance) {
invokeArrayFns(bu);
}
effect.allowRecurse = true;
patch(instance);
patch(instance, renderComponentRoot(instance));
// updated hook
if (u) {
queuePostRenderEffect$1(u);
......
......@@ -8,8 +8,7 @@ export default {
const oldMount = app.mount
app.mount = function mount(rootContainer: any) {
const instance = oldMount.call(app, rootContainer)
// @ts-ignore
createMiniProgramApp(instance)
;(global as any).createApp(instance)
return instance
}
},
......
......@@ -26,7 +26,6 @@
]
},
"replacements": {
"global": "global",
"__GLOBAL__": "wx",
"__PLATFORM__": "\"mp-weixin\"",
"__PLATFORM_TITLE__": "微信小程序"
......
......@@ -7,11 +7,24 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
var initMiniProgramPlugin__default = /*#__PURE__*/_interopDefaultLegacy(initMiniProgramPlugin);
var index = initMiniProgramPlugin__default["default"]({
global: 'wx',
alias: {
'uni-mp-runtime': uniCliShared.resolveBuiltIn('@dcloudio/uni-mp-weixin/dist/uni.mp.esm.js'),
const uniMiniProgramWeixinPlugin = {
name: 'vite:uni-mp-weixin',
config() {
return {
define: {
__VUE_CREATED_DEFERRED__: JSON.stringify('false'),
},
};
},
});
};
var index = [
uniMiniProgramWeixinPlugin,
...initMiniProgramPlugin__default["default"]({
global: 'wx',
alias: {
'uni-mp-runtime': uniCliShared.resolveBuiltIn('@dcloudio/uni-mp-weixin/dist/uni.mp.esm.js'),
},
}),
];
module.exports = index;
......@@ -1178,7 +1178,7 @@ var parseOptions = /*#__PURE__*/Object.freeze({
const createApp = initCreateApp();
const createPage = initCreatePage(parseOptions);
const createComponent = initCreateComponent(parseOptions);
wx.createApp = createApp;
wx.createApp = global.createApp = createApp;
wx.createPage = createPage;
wx.createComponent = createComponent;
......
import { Plugin } from 'vite'
import { resolveBuiltIn } from '@dcloudio/uni-cli-shared'
import initMiniProgramPlugin from '@dcloudio/uni-mp-vite'
export default initMiniProgramPlugin({
global: 'wx',
alias: {
'uni-mp-runtime': resolveBuiltIn(
'@dcloudio/uni-mp-weixin/dist/uni.mp.esm.js'
),
const uniMiniProgramWeixinPlugin: Plugin = {
name: 'vite:uni-mp-weixin',
config() {
return {
define: {
__VUE_CREATED_DEFERRED__: JSON.stringify('false'),
},
}
},
})
}
export default [
uniMiniProgramWeixinPlugin,
...initMiniProgramPlugin({
global: 'wx',
alias: {
'uni-mp-runtime': resolveBuiltIn(
'@dcloudio/uni-mp-weixin/dist/uni.mp.esm.js'
),
},
}),
]
......@@ -11,6 +11,6 @@ import * as parseOptions from './parseOptions'
export const createApp = initCreateApp()
export const createPage = initCreatePage(parseOptions)
export const createComponent = initCreateComponent(parseOptions)
;(wx as any).createApp = createApp
;(wx as any).createApp = (global as any).createApp = createApp
;(wx as any).createPage = createPage
;(wx as any).createComponent = createComponent
......@@ -16,7 +16,6 @@
]
},
"replacements": {
"global": "global",
"__GLOBAL__": "qa",
"__PLATFORM__": "\"quickapp-webview\"",
"__PLATFORM_TITLE__": "快应用(Webview)版"
......
......@@ -1328,7 +1328,7 @@ const createApp = initCreateApp();
const createPage = initCreatePage(parsePageOptions);
const createComponent = initCreateComponent(parseComponentOptions);
qa.EventChannel = EventChannel;
qa.createApp = createApp;
qa.createApp = global.createApp = createApp;
qa.createPage = createPage;
qa.createComponent = createComponent;
......
......@@ -14,6 +14,6 @@ export const createApp = initCreateApp()
export const createPage = initCreatePage(parsePageOptions)
export const createComponent = initCreateComponent(parseComponentOptions)
;(qa as any).EventChannel = EventChannel
;(qa as any).createApp = createApp
;(qa as any).createApp = (global as any).createApp = createApp
;(qa as any).createPage = createPage
;(qa as any).createComponent = createComponent
......@@ -184,11 +184,13 @@ function createAliasPlugin(buildOption) {
function createReplacePlugin(buildOption, format) {
const replacements = {
global: format === 'cjs' ? 'global' : 'window',
__DEV__: `(process.env.NODE_ENV !== 'production')`,
__TEST__: false,
__NODE_JS__: format === 'cjs',
}
// if (process.env.TARGET === 'uni-h5') {
// replacements.global = format === 'cjs' ? 'global' : 'window'
// }
if (buildOption.replacements) {
Object.assign(replacements, buildOption.replacements)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册