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

feat: tree-shaking

上级 8a656509
import { cacheStringFunction } from '@dcloudio/uni-shared'
import { Ref, SetupContext, EmitsOptions } from 'vue'
type EventDetail = Record<string, any>
......@@ -31,15 +32,7 @@ function normalizeCustomEvent(
}
}
function cached(fn: Function) {
const cache = Object.create(null)
return function cachedFn(str: string) {
const hit = cache[str]
return hit || (cache[str] = fn(str))
}
}
const firstLetterToLowerCase = cached((str: string) => {
const firstLetterToLowerCase = cacheStringFunction((str: string) => {
return str.charAt(0).toLowerCase() + str.slice(1)
})
......
......@@ -6,7 +6,7 @@ export interface UserActionState {
userAction: boolean
}
const passiveOptions = passive(true)
const passiveOptions = /*#__PURE__*/ passive(true)
const states: UserActionState[] = []
let userInteract: number = 0
let inited: boolean
......
......@@ -5,8 +5,8 @@ import MovableArea from './movable-area'
import MovableView from './movable-view'
export default {
Navigator,
/* Label,
Label,
Button,
MovableArea,
MovableView */
MovableView,
}
......@@ -8,7 +8,7 @@ type LabelTarget = HTMLElement & {
attr: { dataUncType: string }
}
export default defineComponent({
export default /*#__PURE__*/ defineComponent({
name: 'Label',
props,
styles: [],
......
......@@ -19,7 +19,7 @@ import {
CustomEventTrigger,
EmitEvent,
useCustomEvent,
} from '../../helpers/useNvueEvent'
} from '../../helpers/useNVueEvent'
import {
MovableViewContext,
AddMovableViewContext,
......
......@@ -12,7 +12,7 @@ import {
import { extend } from '@vue/shared'
import { props, GetPickerViewColumn } from '../../components/picker-view'
import { flatVNode } from '../../helpers/flatVNode'
import { useCustomEvent, EmitEvent } from '../../helpers/useNvueEvent'
import { useCustomEvent, EmitEvent } from '../../helpers/useNVueEvent'
export { Props, GetPickerViewColumn }
const pickerViewProps = extend({}, props, {
......
......@@ -34,7 +34,7 @@ interface State {
refreshState: RefreshState
}
const passiveOptions = passive(true)
const passiveOptions = /*#__PURE__*/ passive(true)
const props = {
scrollX: {
......
......@@ -11,7 +11,19 @@ export default defineConfig({
root: __dirname,
define: {
global: 'window',
__PLATFORM__: "'app'",
__DEV__: `(process.env.NODE_ENV !== 'production')`,
__NODE_JS__: false,
__APP_VIEW__: false,
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
__UNI_FEATURE_WX__: true,
__UNI_FEATURE_PROMISE__: false,
__UNI_FEATURE_I18N_EN__: true,
__UNI_FEATURE_I18N_ES__: true,
__UNI_FEATURE_I18N_FR__: true,
__UNI_FEATURE_I18N_ZH_HANS__: true,
__UNI_FEATURE_I18N_ZH_HANT__: true,
},
resolve: {
alias: [
......@@ -26,21 +38,12 @@ export default defineConfig({
lib: {
name: 'components',
entry: path.resolve(__dirname, 'src/nvue/components.ts'),
formats: ['iife'],
formats: ['es'],
},
rollupOptions: {
external: ['uni', 'vue', 'weex', '@vue/shared'],
external: ['uni', 'vue', 'weex', '@vue/shared', '@dcloudio/uni-shared'],
output: {
banner:
'export function initComponents({uni,Vue,weex,plus,BroadcastChannel,UniViewJSBridge,VueShared}) {',
footer: 'return components\n}',
entryFileNames: 'components.js',
globals: {
uni: 'uni',
vue: 'Vue',
weex: 'weex',
'@vue/shared': 'VueShared',
},
},
},
},
......
import { once } from '@dcloudio/uni-shared'
export const isEnableLocale = once(
export const isEnableLocale = /*#__PURE__*/ once(
() =>
typeof __uniConfig !== 'undefined' &&
__uniConfig.locales &&
......
......@@ -5,7 +5,9 @@ import { invokeOnCallback } from './invokeOnCallback'
import { invokeViewMethod, invokeViewMethodKeepAlive } from './invokeViewMethod'
export const ServiceJSBridge = /*#__PURE__*/ extend(
initBridge('view' /* view 指的是 service 层订阅的是 view 层事件 */),
/*#__PURE__*/ initBridge(
'view' /* view 指的是 service 层订阅的是 view 层事件 */
),
{
invokeOnCallback,
invokeViewMethod,
......
......@@ -3,9 +3,12 @@ import { extend } from '@vue/shared'
import { initBridge } from '../../helpers/bridge'
import { invokeServiceMethod } from './invokeServiceMethod'
export const ViewJSBridge = /*#__PURE__*/ extend(initBridge('service'), {
invokeServiceMethod,
})
export const ViewJSBridge = /*#__PURE__*/ extend(
/*#__PURE__*/ initBridge('service'),
{
invokeServiceMethod,
}
)
export {
subscribeViewMethod,
......
......@@ -3,7 +3,7 @@ import { passive } from '@dcloudio/uni-shared'
const LONGPRESS_TIMEOUT = 350
const LONGPRESS_THRESHOLD = 10
const passiveOptions = passive(true)
const passiveOptions = /*#__PURE__*/ passive(true)
let longPressTimer: ReturnType<typeof setTimeout> | null
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册