提交 8ed4e2b1 编写于 作者: fxy060608's avatar fxy060608

fix(vue3-mp): export defineComponent...

上级 9d30f60b
import { isSymbol, extend, isMap, isObject, toRawType, def, isArray, isString, isFunction, isPromise, toHandlerKey, remove, EMPTY_OBJ, NOOP, isGloballyWhitelisted, isIntegerKey, hasOwn, hasChanged, capitalize, NO, invokeArrayFns, isSet, makeMap, toNumber, hyphenate, camelize, isReservedProp, EMPTY_ARR, toTypeString, isOn } from '@vue/shared';
import { isSymbol, extend, isMap, isObject, toRawType, def, isArray, isString, isFunction, isPromise, capitalize, toHandlerKey, remove, EMPTY_OBJ, NOOP, isGloballyWhitelisted, isIntegerKey, hasOwn, hasChanged, camelize, NO, invokeArrayFns, isSet, makeMap, toNumber, hyphenate, isReservedProp, EMPTY_ARR, toTypeString, isOn } from '@vue/shared';
export { camelize } from '@vue/shared';
const targetMap = new WeakMap();
......@@ -1366,6 +1366,57 @@ let currentRenderingInstance = null;
function markAttrsAccessed() {
}
const COMPONENTS = 'components';
const DIRECTIVES = 'directives';
/**
* @private
*/
function resolveDirective(name) {
return resolveAsset(DIRECTIVES, name);
}
// implementation
function resolveAsset(type, name, warnMissing = true) {
const instance = currentInstance;
if (instance) {
const Component = instance.type;
// self name has highest priority
if (type === COMPONENTS) {
// special self referencing call generated by compiler
// inferred from SFC filename
if (name === `_self`) {
return Component;
}
const selfName = Component.displayName || Component.name;
if (selfName &&
(selfName === name ||
selfName === camelize(name) ||
selfName === capitalize(camelize(name)))) {
return Component;
}
}
const res =
// local registration
// check instance[type] first for components with mixin or extends.
resolve(instance[type] || Component[type], name) ||
// global registration
resolve(instance.appContext[type], name);
if ((process.env.NODE_ENV !== 'production') && warnMissing && !res) {
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
}
return res;
}
else if ((process.env.NODE_ENV !== 'production')) {
warn(`resolve${capitalize(type.slice(0, -1))} ` +
`can only be used in render() or setup().`);
}
}
function resolve(registry, name) {
return (registry &&
(registry[name] ||
registry[camelize(name)] ||
registry[capitalize(camelize(name))]));
}
function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
isSSR = false) {
const props = {};
......@@ -1798,6 +1849,15 @@ function validateDirectiveName(name) {
if (isBuiltInDirective(name)) {
warn('Do not use built-in directive ids as custom directive id: ' + name);
}
}
/**
* Adds directives to a VNode.
*/
function withDirectives(vnode, directives) {
{
(process.env.NODE_ENV !== 'production') && warn(`withDirectives can only be used inside render functions.`);
return vnode;
}
}
function createAppContext() {
......@@ -1928,6 +1988,11 @@ function createAppAPI() {
};
}
// implementation, close to no-op
function defineComponent(options) {
return isFunction(options) ? { setup: options, name: options.name } : options;
}
const queuePostRenderEffect = queuePostFlushCb;
// Simple effect.
......@@ -3158,6 +3223,25 @@ function computed$1(getterOrOptions) {
return c;
}
// implementation
function defineProps() {
if ((process.env.NODE_ENV !== 'production')) {
warn(`defineProps() is a compiler-hint helper that is only usable inside ` +
`<script setup> of a single file component. Its arguments should be ` +
`compiled away and passing it at runtime has no effect.`);
}
return null;
}
// implementation
function defineEmit() {
if ((process.env.NODE_ENV !== 'production')) {
warn(`defineEmit() is a compiler-hint helper that is only usable inside ` +
`<script setup> of a single file component. Its arguments should be ` +
`compiled away and passing it at runtime has no effect.`);
}
return null;
}
// Core API ------------------------------------------------------------------
const version = "3.0.3";
......@@ -3685,4 +3769,4 @@ function createApp(rootComponent, rootProps = null) {
return createVueApp(rootComponent, rootProps).use(plugin);
}
export { callWithAsyncErrorHandling, callWithErrorHandling, computed$1 as computed, createApp, createHook$1 as createHook, createVueApp, customRef, inject, injectHook, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, logError, markRaw, nextTick, onActivated, onAddToFavorites, onBackPress, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMounted, onNavigationBarButtonTap, onNavigationBarSearchInputChanged, onNavigationBarSearchInputClicked, onNavigationBarSearchInputConfirmed, onNavigationBarSearchInputFocusChanged, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onRenderTracked, onRenderTriggered, onResize, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, provide, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, version, warn, watch, watchEffect };
export { callWithAsyncErrorHandling, callWithErrorHandling, computed$1 as computed, createApp, createHook$1 as createHook, createVueApp, customRef, defineComponent, defineEmit, defineProps, inject, injectHook, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, logError, markRaw, nextTick, onActivated, onAddToFavorites, onBackPress, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMounted, onNavigationBarButtonTap, onNavigationBarSearchInputChanged, onNavigationBarSearchInputClicked, onNavigationBarSearchInputConfirmed, onNavigationBarSearchInputFocusChanged, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onRenderTracked, onRenderTriggered, onResize, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, provide, reactive, readonly, ref, resolveDirective, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, version, warn, watch, watchEffect, withDirectives };
......@@ -27,6 +27,9 @@ module.exports = function modifyVueLoader (webpackConfig, loaderOptions, compile
.tap(options => Object.assign(options, vueLoader.options(loaderOptions, compilerOptions), cacheConfig))
.end()
// 强制使用vue2,vue3时会使用vue-loader-v16
webpackConfig.plugin('vue-loader').use(require(vueLoader.loader).VueLoaderPlugin)
// h5 框架需要使用 scoped 样式,其他平台编译时识别是否 nvue 文件且注入 flex 相关样式
if (process.env.UNI_PLATFORM === 'h5') {
webpackConfig.module
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册