@mpxjs/webpack-plugin 2.10.21 → 2.10.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/loader.js CHANGED
@@ -154,6 +154,7 @@ module.exports = function (content) {
154
154
  usingComponentsInfo,
155
155
  originalUsingComponents,
156
156
  componentGenerics,
157
+ componentPlaceholder,
157
158
  autoScope,
158
159
  callback
159
160
  })
@@ -177,6 +178,7 @@ module.exports = function (content) {
177
178
  usingComponentsInfo,
178
179
  originalUsingComponents,
179
180
  componentGenerics,
181
+ componentPlaceholder,
180
182
  autoScope,
181
183
  callback
182
184
  })
@@ -23,6 +23,7 @@ module.exports = function ({
23
23
  usingComponentsInfo,
24
24
  originalUsingComponents,
25
25
  componentGenerics,
26
+ componentPlaceholder,
26
27
  autoScope,
27
28
  callback
28
29
  }) {
@@ -55,7 +56,8 @@ module.exports = function ({
55
56
  ctorType,
56
57
  usingComponentsInfo,
57
58
  originalUsingComponents,
58
- componentGenerics
59
+ componentGenerics,
60
+ componentPlaceholder
59
61
  }, callback)
60
62
  },
61
63
  (callback) => {
@@ -32,7 +32,8 @@ module.exports = function (template, {
32
32
  ctorType,
33
33
  usingComponentsInfo,
34
34
  originalUsingComponents,
35
- componentGenerics
35
+ componentGenerics,
36
+ componentPlaceholder
36
37
  }, callback) {
37
38
  const mpx = loaderContext.getMpx()
38
39
  const {
@@ -103,6 +104,7 @@ module.exports = function (template, {
103
104
  i18n: null,
104
105
  // 与 template-compiler/index 一致:usingComponentsInfo 已合并 globalComponentsInfo,此处白名单避免对仅 app 注册的组件误报「未使用」
105
106
  globalComponents: Object.keys(globalComponents || {}),
107
+ componentPlaceholder,
106
108
  // rn模式下实现抽象组件
107
109
  componentGenerics,
108
110
  hasVirtualHost: matchCondition(resourcePath, autoVirtualHostRules),
@@ -5,13 +5,13 @@ import { extendObject, getDefaultAllowFontScaling, useTextPassThroughValue, wrap
5
5
  import { TextPassThroughContext } from './context';
6
6
  import * as perf from '@mpxjs/perf';
7
7
  const SimpleText = (props) => {
8
- let stopTotal;
8
+ let idTotal = -1;
9
9
  if (__mpx_perf_framework__)
10
- stopTotal = perf.scope('simple-text:render:total');
10
+ idTotal = perf.scopeStart('simple-text:render:total');
11
11
  // ───── style 阶段 ─────
12
- let stopStyle;
12
+ let idStyle = -1;
13
13
  if (__mpx_perf_framework__)
14
- stopStyle = perf.scope('simple-text:render:style');
14
+ idStyle = perf.scopeStart('simple-text:render:style');
15
15
  const inheritedText = useContext(TextPassThroughContext);
16
16
  const mergedStyle = extendObject({}, inheritedText?.textStyle, props.style);
17
17
  let hasBoxSizingAffectingStyle = false;
@@ -30,29 +30,29 @@ const SimpleText = (props) => {
30
30
  disabled: isStringOnly
31
31
  });
32
32
  if (__mpx_perf_framework__)
33
- stopStyle();
33
+ perf.scopeEnd(idStyle);
34
34
  // ───── innerProps 阶段 ─────
35
- let stopInnerProps;
35
+ let idInnerProps = -1;
36
36
  if (__mpx_perf_framework__)
37
- stopInnerProps = perf.scope('simple-text:render:innerProps');
37
+ idInnerProps = perf.scopeStart('simple-text:render:innerProps');
38
38
  const innerProps = useInnerProps(extendObject({}, mergedProps, {
39
39
  allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
40
40
  style: finalStyle
41
41
  }));
42
42
  if (__mpx_perf_framework__)
43
- stopInnerProps();
43
+ perf.scopeEnd(idInnerProps);
44
44
  // ───── createElement 阶段 ─────
45
- let stopCreate;
45
+ let idCreate = -1;
46
46
  if (__mpx_perf_framework__)
47
- stopCreate = perf.scope('simple-text:render:createElement');
47
+ idCreate = perf.scopeStart('simple-text:render:createElement');
48
48
  const result = createElement(Text, innerProps, wrapChildren({ children }, {
49
49
  hasVarDec: false,
50
50
  textPassThrough: childTextPassThrough
51
51
  }));
52
52
  if (__mpx_perf_framework__)
53
- stopCreate();
53
+ perf.scopeEnd(idCreate);
54
54
  if (__mpx_perf_framework__)
55
- stopTotal();
55
+ perf.scopeEnd(idTotal);
56
56
  return result;
57
57
  };
58
58
  SimpleText.displayName = 'MpxSimpleText';
@@ -4,13 +4,13 @@ import { splitProps, splitStyle, wrapChildren, extendObject, useTextPassThroughV
4
4
  import useInnerProps from './getInnerListeners';
5
5
  import * as perf from '@mpxjs/perf';
6
6
  const SimpleView = (simpleViewProps) => {
7
- let stopTotal;
7
+ let idTotal = -1;
8
8
  if (__mpx_perf_framework__)
9
- stopTotal = perf.scope('simple-view:render:total');
9
+ idTotal = perf.scopeStart('simple-view:render:total');
10
10
  // ───── style 阶段 ─────
11
- let stopStyle;
11
+ let idStyle = -1;
12
12
  if (__mpx_perf_framework__)
13
- stopStyle = perf.scope('simple-view:render:style');
13
+ idStyle = perf.scopeStart('simple-view:render:style');
14
14
  const { textProps, innerProps: props = {} } = splitProps(simpleViewProps);
15
15
  let hasBoxSizingAffectingStyle = false;
16
16
  const { textStyle, innerStyle = {} } = splitStyle(props.style || {}, (key) => {
@@ -20,28 +20,28 @@ const SimpleView = (simpleViewProps) => {
20
20
  });
21
21
  const textPassThrough = useTextPassThroughValue(textStyle, textProps);
22
22
  if (__mpx_perf_framework__)
23
- stopStyle();
23
+ perf.scopeEnd(idStyle);
24
24
  // ───── innerProps 阶段 ─────
25
- let stopInnerProps;
25
+ let idInnerProps = -1;
26
26
  if (__mpx_perf_framework__)
27
- stopInnerProps = perf.scope('simple-view:render:innerProps');
27
+ idInnerProps = perf.scopeStart('simple-view:render:innerProps');
28
28
  const innerProps = useInnerProps(extendObject({}, props, {
29
29
  style: transformBoxSizing(extendObject({}, innerStyle), hasBoxSizingAffectingStyle)
30
30
  }));
31
31
  if (__mpx_perf_framework__)
32
- stopInnerProps();
32
+ perf.scopeEnd(idInnerProps);
33
33
  // ───── createElement 阶段 ─────
34
- let stopCreate;
34
+ let idCreate = -1;
35
35
  if (__mpx_perf_framework__)
36
- stopCreate = perf.scope('simple-view:render:createElement');
36
+ idCreate = perf.scopeStart('simple-view:render:createElement');
37
37
  const result = createElement(View, innerProps, wrapChildren(props, {
38
38
  hasVarDec: false,
39
39
  textPassThrough
40
40
  }));
41
41
  if (__mpx_perf_framework__)
42
- stopCreate();
42
+ perf.scopeEnd(idCreate);
43
43
  if (__mpx_perf_framework__)
44
- stopTotal();
44
+ perf.scopeEnd(idTotal);
45
45
  return result;
46
46
  };
47
47
  SimpleView.displayName = 'MpxSimpleView';
@@ -36,22 +36,22 @@ function getDecodedChildren(children) {
36
36
  });
37
37
  }
38
38
  const _Text = forwardRef((props, ref) => {
39
- let stopTotal;
39
+ let idTotal = -1;
40
40
  if (__mpx_perf_framework__)
41
- stopTotal = perf.scope('text:render:total');
41
+ idTotal = perf.scopeStart('text:render:total');
42
42
  // ───── props 阶段 ─────
43
- let stopProps;
43
+ let idProps = -1;
44
44
  if (__mpx_perf_framework__)
45
- stopProps = perf.scope('text:render:props');
45
+ idProps = perf.scopeStart('text:render:props');
46
46
  const inheritedText = useContext(TextPassThroughContext);
47
47
  const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props);
48
48
  const { style: currentStyle = {}, allowFontScaling, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = mergedProps;
49
49
  if (__mpx_perf_framework__)
50
- stopProps();
50
+ perf.scopeEnd(idProps);
51
51
  // ───── style 阶段 ─────
52
- let stopStyle;
52
+ let idStyle = -1;
53
53
  if (__mpx_perf_framework__)
54
- stopStyle = perf.scope('text:render:style');
54
+ idStyle = perf.scopeStart('text:render:style');
55
55
  const { normalStyle, hasVarDec, varContextRef, hasPositionFixed } = useTransformStyle(currentStyle, {
56
56
  enableVar,
57
57
  externalVarContext,
@@ -76,11 +76,11 @@ const _Text = forwardRef((props, ref) => {
76
76
  disabled: isStringOnly
77
77
  });
78
78
  if (__mpx_perf_framework__)
79
- stopStyle();
79
+ perf.scopeEnd(idStyle);
80
80
  // ───── innerProps 阶段 ─────
81
- let stopInnerProps;
81
+ let idInnerProps = -1;
82
82
  if (__mpx_perf_framework__)
83
- stopInnerProps = perf.scope('text:render:innerProps');
83
+ idInnerProps = perf.scopeStart('text:render:innerProps');
84
84
  const innerProps = useInnerProps(extendObject({}, mergedProps, {
85
85
  ref: nodeRef,
86
86
  style: finalStyle,
@@ -91,11 +91,11 @@ const _Text = forwardRef((props, ref) => {
91
91
  'decode'
92
92
  ]);
93
93
  if (__mpx_perf_framework__)
94
- stopInnerProps();
94
+ perf.scopeEnd(idInnerProps);
95
95
  // ───── createElement 阶段 ─────
96
- let stopCreate;
96
+ let idCreate = -1;
97
97
  if (__mpx_perf_framework__)
98
- stopCreate = perf.scope('text:render:createElement');
98
+ idCreate = perf.scopeStart('text:render:createElement');
99
99
  let finalComponent = createElement(Text, innerProps, wrapChildren(extendObject({}, mergedProps, {
100
100
  children
101
101
  }), {
@@ -107,9 +107,9 @@ const _Text = forwardRef((props, ref) => {
107
107
  finalComponent = createElement(Portal, null, finalComponent);
108
108
  }
109
109
  if (__mpx_perf_framework__)
110
- stopCreate();
110
+ perf.scopeEnd(idCreate);
111
111
  if (__mpx_perf_framework__)
112
- stopTotal();
112
+ perf.scopeEnd(idTotal);
113
113
  return finalComponent;
114
114
  });
115
115
  _Text.displayName = 'MpxText';
@@ -566,13 +566,13 @@ function wrapWithChildren(props, { hasVarDec, enableBackground, backgroundStyle,
566
566
  }
567
567
  const _View = forwardRef((viewProps, ref) => {
568
568
  // 性能探针 - total
569
- let stopTotal;
569
+ let idTotal = -1;
570
570
  if (__mpx_perf_framework__)
571
- stopTotal = perf.scope('view:render:total');
571
+ idTotal = perf.scopeStart('view:render:total');
572
572
  // ───── props 阶段 ─────
573
- let stopProps;
573
+ let idProps = -1;
574
574
  if (__mpx_perf_framework__)
575
- stopProps = perf.scope('view:render:props');
575
+ idProps = perf.scopeStart('view:render:props');
576
576
  const { textProps, innerProps: props = {} } = splitProps(viewProps);
577
577
  let { style = {}, 'hover-style': hoverStyle, 'hover-start-time': hoverStartTime = 50, 'hover-stay-time': hoverStayTime = 400, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'enable-background': enableBackground, 'enable-fast-image': enableFastImage, 'enable-animation': enableAnimation, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, animation, catchtransitionend, bindtransitionend } = props;
578
578
  // 默认样式
@@ -588,11 +588,11 @@ const _View = forwardRef((viewProps, ref) => {
588
588
  const { isHover, gesture } = useHover({ enableHover, hoverStartTime, hoverStayTime });
589
589
  const styleObj = extendObject({}, defaultStyle, style, isHover ? hoverStyle : {});
590
590
  if (__mpx_perf_framework__)
591
- stopProps();
591
+ perf.scopeEnd(idProps);
592
592
  // ───── style 阶段 ─────
593
- let stopStyle;
593
+ let idStyle = -1;
594
594
  if (__mpx_perf_framework__)
595
- stopStyle = perf.scope('view:render:style');
595
+ idStyle = perf.scopeStart('view:render:style');
596
596
  const { normalStyle, hasSelfPercent, hasPositionFixed, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, {
597
597
  enableVar,
598
598
  externalVarContext,
@@ -626,11 +626,11 @@ const _View = forwardRef((viewProps, ref) => {
626
626
  transitionend
627
627
  });
628
628
  if (__mpx_perf_framework__)
629
- stopStyle();
629
+ perf.scopeEnd(idStyle);
630
630
  // ───── innerProps 阶段 ─────
631
- let stopInnerProps;
631
+ let idInnerProps = -1;
632
632
  if (__mpx_perf_framework__)
633
- stopInnerProps = perf.scope('view:render:innerProps');
633
+ idInnerProps = perf.scopeStart('view:render:innerProps');
634
634
  const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
635
635
  ref: nodeRef,
636
636
  style: enableStyleAnimation ? [viewStyle, animationStyle] : viewStyle
@@ -648,11 +648,11 @@ const _View = forwardRef((viewProps, ref) => {
648
648
  layoutRef
649
649
  });
650
650
  if (__mpx_perf_framework__)
651
- stopInnerProps();
651
+ perf.scopeEnd(idInnerProps);
652
652
  // ───── createElement 阶段 ─────
653
- let stopCreate;
653
+ let idCreate = -1;
654
654
  if (__mpx_perf_framework__)
655
- stopCreate = perf.scope('view:render:createElement');
655
+ idCreate = perf.scopeStart('view:render:createElement');
656
656
  const childNode = wrapWithChildren(props, {
657
657
  hasVarDec,
658
658
  enableBackground: enableBackgroundRef.current,
@@ -672,9 +672,9 @@ const _View = forwardRef((viewProps, ref) => {
672
672
  finalComponent = createElement(Portal, null, finalComponent);
673
673
  }
674
674
  if (__mpx_perf_framework__)
675
- stopCreate();
675
+ perf.scopeEnd(idCreate);
676
676
  if (__mpx_perf_framework__)
677
- stopTotal();
677
+ perf.scopeEnd(idTotal);
678
678
  return finalComponent;
679
679
  });
680
680
  _View.displayName = 'MpxView';
@@ -6,12 +6,12 @@ import { TextPassThroughContext } from './context'
6
6
  import * as perf from '@mpxjs/perf'
7
7
 
8
8
  const SimpleText = (props: TextProps): JSX.Element => {
9
- let stopTotal: (() => void) | undefined
10
- if (__mpx_perf_framework__) stopTotal = perf.scope('simple-text:render:total')
9
+ let idTotal = -1
10
+ if (__mpx_perf_framework__) idTotal = perf.scopeStart('simple-text:render:total')
11
11
 
12
12
  // ───── style 阶段 ─────
13
- let stopStyle: (() => void) | undefined
14
- if (__mpx_perf_framework__) stopStyle = perf.scope('simple-text:render:style')
13
+ let idStyle = -1
14
+ if (__mpx_perf_framework__) idStyle = perf.scopeStart('simple-text:render:style')
15
15
  const inheritedText = useContext(TextPassThroughContext)
16
16
  const mergedStyle = extendObject({}, inheritedText?.textStyle, props.style)
17
17
  let hasBoxSizingAffectingStyle = false
@@ -36,11 +36,11 @@ const SimpleText = (props: TextProps): JSX.Element => {
36
36
  disabled: isStringOnly
37
37
  }
38
38
  )
39
- if (__mpx_perf_framework__) stopStyle!()
39
+ if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
40
40
 
41
41
  // ───── innerProps 阶段 ─────
42
- let stopInnerProps: (() => void) | undefined
43
- if (__mpx_perf_framework__) stopInnerProps = perf.scope('simple-text:render:innerProps')
42
+ let idInnerProps = -1
43
+ if (__mpx_perf_framework__) idInnerProps = perf.scopeStart('simple-text:render:innerProps')
44
44
  const innerProps = useInnerProps(
45
45
  extendObject(
46
46
  {},
@@ -51,11 +51,11 @@ const SimpleText = (props: TextProps): JSX.Element => {
51
51
  }
52
52
  )
53
53
  )
54
- if (__mpx_perf_framework__) stopInnerProps!()
54
+ if (__mpx_perf_framework__) perf.scopeEnd(idInnerProps)
55
55
 
56
56
  // ───── createElement 阶段 ─────
57
- let stopCreate: (() => void) | undefined
58
- if (__mpx_perf_framework__) stopCreate = perf.scope('simple-text:render:createElement')
57
+ let idCreate = -1
58
+ if (__mpx_perf_framework__) idCreate = perf.scopeStart('simple-text:render:createElement')
59
59
  const result = createElement(Text, innerProps, wrapChildren(
60
60
  { children },
61
61
  {
@@ -63,9 +63,9 @@ const SimpleText = (props: TextProps): JSX.Element => {
63
63
  textPassThrough: childTextPassThrough
64
64
  }
65
65
  ))
66
- if (__mpx_perf_framework__) stopCreate!()
66
+ if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
67
67
 
68
- if (__mpx_perf_framework__) stopTotal!()
68
+ if (__mpx_perf_framework__) perf.scopeEnd(idTotal)
69
69
  return result
70
70
  }
71
71
 
@@ -5,12 +5,12 @@ import useInnerProps from './getInnerListeners'
5
5
  import * as perf from '@mpxjs/perf'
6
6
 
7
7
  const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
8
- let stopTotal: (() => void) | undefined
9
- if (__mpx_perf_framework__) stopTotal = perf.scope('simple-view:render:total')
8
+ let idTotal = -1
9
+ if (__mpx_perf_framework__) idTotal = perf.scopeStart('simple-view:render:total')
10
10
 
11
11
  // ───── style 阶段 ─────
12
- let stopStyle: (() => void) | undefined
13
- if (__mpx_perf_framework__) stopStyle = perf.scope('simple-view:render:style')
12
+ let idStyle = -1
13
+ if (__mpx_perf_framework__) idStyle = perf.scopeStart('simple-view:render:style')
14
14
  const { textProps, innerProps: props = {} } = splitProps(simpleViewProps)
15
15
 
16
16
  let hasBoxSizingAffectingStyle = false
@@ -20,11 +20,11 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
20
20
  }
21
21
  })
22
22
  const textPassThrough = useTextPassThroughValue(textStyle as TextStyle, textProps)
23
- if (__mpx_perf_framework__) stopStyle!()
23
+ if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
24
24
 
25
25
  // ───── innerProps 阶段 ─────
26
- let stopInnerProps: (() => void) | undefined
27
- if (__mpx_perf_framework__) stopInnerProps = perf.scope('simple-view:render:innerProps')
26
+ let idInnerProps = -1
27
+ if (__mpx_perf_framework__) idInnerProps = perf.scopeStart('simple-view:render:innerProps')
28
28
  const innerProps = useInnerProps(
29
29
  extendObject(
30
30
  {},
@@ -34,11 +34,11 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
34
34
  }
35
35
  )
36
36
  )
37
- if (__mpx_perf_framework__) stopInnerProps!()
37
+ if (__mpx_perf_framework__) perf.scopeEnd(idInnerProps)
38
38
 
39
39
  // ───── createElement 阶段 ─────
40
- let stopCreate: (() => void) | undefined
41
- if (__mpx_perf_framework__) stopCreate = perf.scope('simple-view:render:createElement')
40
+ let idCreate = -1
41
+ if (__mpx_perf_framework__) idCreate = perf.scopeStart('simple-view:render:createElement')
42
42
  const result = createElement(View, innerProps, wrapChildren(
43
43
  props,
44
44
  {
@@ -46,9 +46,9 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
46
46
  textPassThrough
47
47
  }
48
48
  ))
49
- if (__mpx_perf_framework__) stopCreate!()
49
+ if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
50
50
 
51
- if (__mpx_perf_framework__) stopTotal!()
51
+ if (__mpx_perf_framework__) perf.scopeEnd(idTotal)
52
52
  return result
53
53
  }
54
54
 
@@ -53,12 +53,12 @@ interface _TextProps extends TextProps {
53
53
  }
54
54
 
55
55
  const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref): JSX.Element => {
56
- let stopTotal: (() => void) | undefined
57
- if (__mpx_perf_framework__) stopTotal = perf.scope('text:render:total')
56
+ let idTotal = -1
57
+ if (__mpx_perf_framework__) idTotal = perf.scopeStart('text:render:total')
58
58
 
59
59
  // ───── props 阶段 ─────
60
- let stopProps: (() => void) | undefined
61
- if (__mpx_perf_framework__) stopProps = perf.scope('text:render:props')
60
+ let idProps = -1
61
+ if (__mpx_perf_framework__) idProps = perf.scopeStart('text:render:props')
62
62
  const inheritedText = useContext(TextPassThroughContext)
63
63
  const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props)
64
64
  const {
@@ -73,11 +73,11 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
73
73
  'parent-height': parentHeight,
74
74
  decode
75
75
  } = mergedProps
76
- if (__mpx_perf_framework__) stopProps!()
76
+ if (__mpx_perf_framework__) perf.scopeEnd(idProps)
77
77
 
78
78
  // ───── style 阶段 ─────
79
- let stopStyle: (() => void) | undefined
80
- if (__mpx_perf_framework__) stopStyle = perf.scope('text:render:style')
79
+ let idStyle = -1
80
+ if (__mpx_perf_framework__) idStyle = perf.scopeStart('text:render:style')
81
81
  const {
82
82
  normalStyle,
83
83
  hasVarDec,
@@ -112,11 +112,11 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
112
112
  disabled: isStringOnly
113
113
  }
114
114
  )
115
- if (__mpx_perf_framework__) stopStyle!()
115
+ if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
116
116
 
117
117
  // ───── innerProps 阶段 ─────
118
- let stopInnerProps: (() => void) | undefined
119
- if (__mpx_perf_framework__) stopInnerProps = perf.scope('text:render:innerProps')
118
+ let idInnerProps = -1
119
+ if (__mpx_perf_framework__) idInnerProps = perf.scopeStart('text:render:innerProps')
120
120
  const innerProps = useInnerProps(
121
121
  extendObject(
122
122
  {},
@@ -133,11 +133,11 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
133
133
  'decode'
134
134
  ]
135
135
  )
136
- if (__mpx_perf_framework__) stopInnerProps!()
136
+ if (__mpx_perf_framework__) perf.scopeEnd(idInnerProps)
137
137
 
138
138
  // ───── createElement 阶段 ─────
139
- let stopCreate: (() => void) | undefined
140
- if (__mpx_perf_framework__) stopCreate = perf.scope('text:render:createElement')
139
+ let idCreate = -1
140
+ if (__mpx_perf_framework__) idCreate = perf.scopeStart('text:render:createElement')
141
141
  let finalComponent:JSX.Element = createElement(Text, innerProps, wrapChildren(
142
142
  extendObject({}, mergedProps, {
143
143
  children
@@ -152,9 +152,9 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
152
152
  if (hasPositionFixed) {
153
153
  finalComponent = createElement(Portal, null, finalComponent)
154
154
  }
155
- if (__mpx_perf_framework__) stopCreate!()
155
+ if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
156
156
 
157
- if (__mpx_perf_framework__) stopTotal!()
157
+ if (__mpx_perf_framework__) perf.scopeEnd(idTotal)
158
158
  return finalComponent
159
159
  })
160
160
 
@@ -703,12 +703,12 @@ function wrapWithChildren (props: _ViewProps, { hasVarDec, enableBackground, bac
703
703
 
704
704
  const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, ref): JSX.Element => {
705
705
  // 性能探针 - total
706
- let stopTotal: (() => void) | undefined
707
- if (__mpx_perf_framework__) stopTotal = perf.scope('view:render:total')
706
+ let idTotal = -1
707
+ if (__mpx_perf_framework__) idTotal = perf.scopeStart('view:render:total')
708
708
 
709
709
  // ───── props 阶段 ─────
710
- let stopProps: (() => void) | undefined
711
- if (__mpx_perf_framework__) stopProps = perf.scope('view:render:props')
710
+ let idProps = -1
711
+ if (__mpx_perf_framework__) idProps = perf.scopeStart('view:render:props')
712
712
  const { textProps, innerProps: props = {} } = splitProps(viewProps)
713
713
  let {
714
714
  style = {},
@@ -742,11 +742,11 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
742
742
  const { isHover, gesture } = useHover({ enableHover, hoverStartTime, hoverStayTime })
743
743
 
744
744
  const styleObj: ExtendedViewStyle = extendObject({}, defaultStyle, style, isHover ? hoverStyle as ExtendedViewStyle : {})
745
- if (__mpx_perf_framework__) stopProps!()
745
+ if (__mpx_perf_framework__) perf.scopeEnd(idProps)
746
746
 
747
747
  // ───── style 阶段 ─────
748
- let stopStyle: (() => void) | undefined
749
- if (__mpx_perf_framework__) stopStyle = perf.scope('view:render:style')
748
+ let idStyle = -1
749
+ if (__mpx_perf_framework__) idStyle = perf.scopeStart('view:render:style')
750
750
  const {
751
751
  normalStyle,
752
752
  hasSelfPercent,
@@ -796,11 +796,11 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
796
796
  style: viewStyle,
797
797
  transitionend
798
798
  })
799
- if (__mpx_perf_framework__) stopStyle!()
799
+ if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
800
800
 
801
801
  // ───── innerProps 阶段 ─────
802
- let stopInnerProps: (() => void) | undefined
803
- if (__mpx_perf_framework__) stopInnerProps = perf.scope('view:render:innerProps')
802
+ let idInnerProps = -1
803
+ if (__mpx_perf_framework__) idInnerProps = perf.scopeStart('view:render:innerProps')
804
804
  const innerProps = useInnerProps(
805
805
  extendObject(
806
806
  {},
@@ -826,11 +826,11 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
826
826
  layoutRef
827
827
  }
828
828
  )
829
- if (__mpx_perf_framework__) stopInnerProps!()
829
+ if (__mpx_perf_framework__) perf.scopeEnd(idInnerProps)
830
830
 
831
831
  // ───── createElement 阶段 ─────
832
- let stopCreate: (() => void) | undefined
833
- if (__mpx_perf_framework__) stopCreate = perf.scope('view:render:createElement')
832
+ let idCreate = -1
833
+ if (__mpx_perf_framework__) idCreate = perf.scopeStart('view:render:createElement')
834
834
  const childNode = wrapWithChildren(props, {
835
835
  hasVarDec,
836
836
  enableBackground: enableBackgroundRef.current,
@@ -852,9 +852,9 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
852
852
  if (hasPositionFixed) {
853
853
  finalComponent = createElement(Portal, null, finalComponent)
854
854
  }
855
- if (__mpx_perf_framework__) stopCreate!()
855
+ if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
856
856
 
857
- if (__mpx_perf_framework__) stopTotal!()
857
+ if (__mpx_perf_framework__) perf.scopeEnd(idTotal)
858
858
  return finalComponent
859
859
  })
860
860
 
@@ -849,9 +849,13 @@ function parse (template, options) {
849
849
  })
850
850
 
851
851
  if (!tagNames.has('component') && !tagNames.has('template') && options.checkUsingComponents) {
852
+ // usingComponents 与 tagNames 均为 rulesRunner 处理后的名字(capitalToHyphen / mpx-com- 前缀已对齐),
853
+ // 反向排除 globalComponents 以避免对仅在 app 注册的组件误报「未使用」
854
+ const globalComponents = options.globalComponents || []
855
+ const componentPlaceholder = options.componentPlaceholder || []
852
856
  const arr = []
853
857
  usingComponents.forEach((item) => {
854
- if (!tagNames.has(item) && !options.globalComponents.includes(item) && !options.componentPlaceholder.includes(item)) {
858
+ if (!tagNames.has(item) && !globalComponents.includes(item) && !componentPlaceholder.includes(item)) {
855
859
  arr.push(item)
856
860
  }
857
861
  })
@@ -1,6 +1,10 @@
1
1
  const path = require('path')
2
2
  const { codeFrameColumns } = require('@babel/code-frame')
3
- const { SourceMapConsumer } = require('source-map')
3
+ const {
4
+ TraceMap,
5
+ originalPositionFor: traceOriginalPositionFor,
6
+ sourceContentFor
7
+ } = require('@jridgewell/trace-mapping')
4
8
 
5
9
  function offsetToPosition (source, offset) {
6
10
  const before = source.slice(0, offset)
@@ -45,25 +49,17 @@ function createCodeFrame (source, loc) {
45
49
  function originalPositionFor (map, loc) {
46
50
  loc = normalizeLoc(loc)
47
51
  if (!map || !loc || !loc.start) return
48
- if (typeof map === 'string') {
49
- try {
50
- map = JSON.parse(map)
51
- } catch (e) {
52
- return
53
- }
54
- }
55
- let consumer
52
+ let tracer
56
53
  try {
57
- consumer = new SourceMapConsumer(map)
54
+ tracer = new TraceMap(map)
58
55
  } catch (e) {
59
56
  return
60
57
  }
61
- const original = consumer.originalPositionFor({
58
+ const original = traceOriginalPositionFor(tracer, {
62
59
  line: loc.start.line,
63
60
  column: Math.max((loc.start.column || 1) - 1, 0)
64
61
  })
65
62
  if (!original || !original.source || !original.line) return
66
- const sourceIndex = map.sources && map.sources.indexOf(original.source)
67
63
  return {
68
64
  file: original.source,
69
65
  loc: {
@@ -72,7 +68,7 @@ function originalPositionFor (map, loc) {
72
68
  column: (original.column || 0) + 1
73
69
  }
74
70
  },
75
- source: sourceIndex > -1 && map.sourcesContent && map.sourcesContent[sourceIndex],
71
+ source: sourceContentFor(tracer, original.source) || undefined,
76
72
  generatedLoc: loc
77
73
  }
78
74
  }
package/lib/web/index.js CHANGED
@@ -23,6 +23,7 @@ module.exports = function ({
23
23
  usingComponentsInfo,
24
24
  originalUsingComponents,
25
25
  componentGenerics,
26
+ componentPlaceholder,
26
27
  autoScope,
27
28
  callback
28
29
  }) {
@@ -72,7 +73,8 @@ module.exports = function ({
72
73
  ctorType,
73
74
  usingComponentsInfo,
74
75
  originalUsingComponents,
75
- componentGenerics
76
+ componentGenerics,
77
+ componentPlaceholder
76
78
  }, callback)
77
79
  },
78
80
  (callback) => {
@@ -15,7 +15,8 @@ module.exports = function (template, {
15
15
  ctorType,
16
16
  usingComponentsInfo,
17
17
  originalUsingComponents,
18
- componentGenerics
18
+ componentGenerics,
19
+ componentPlaceholder
19
20
  }, callback) {
20
21
  const mpx = loaderContext.getMpx()
21
22
  const {
@@ -99,6 +100,7 @@ module.exports = function (template, {
99
100
  i18n: null,
100
101
  // 与 template-compiler/index 一致:usingComponentsInfo 已合并 globalComponentsInfo,此处白名单避免对仅 app 注册的组件误报「未使用」
101
102
  globalComponents: Object.keys(globalComponents || {}),
103
+ componentPlaceholder,
102
104
  // web模式下实现抽象组件
103
105
  componentGenerics,
104
106
  hasVirtualHost,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.21",
3
+ "version": "2.10.24",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -28,7 +28,8 @@
28
28
  "@better-scroll/slide": "^2.5.1",
29
29
  "@better-scroll/wheel": "^2.5.1",
30
30
  "@better-scroll/zoom": "^2.5.1",
31
- "@mpxjs/perf": "^2.10.21",
31
+ "@jridgewell/trace-mapping": "^0.3.25",
32
+ "@mpxjs/perf": "^2.10.24",
32
33
  "@mpxjs/template-engine": "^2.8.7",
33
34
  "@mpxjs/utils": "^2.10.21",
34
35
  "acorn": "^8.11.3",
@@ -61,11 +62,12 @@
61
62
  "postcss-value-parser": "^4.0.2",
62
63
  "semver": "^7.5.4",
63
64
  "source-list-map": "^2.0.0",
65
+ "source-map": "^0.7.4",
64
66
  "webpack-virtual-modules": "^0.6.0"
65
67
  },
66
68
  "peerDependencies": {
67
69
  "vue": "^2.7.10",
68
- "webpack": "^5.75.0"
70
+ "webpack": "^5.83.1"
69
71
  },
70
72
  "peerDependenciesMeta": {
71
73
  "vue": {
@@ -113,5 +115,5 @@
113
115
  "engines": {
114
116
  "node": ">=14.14.0"
115
117
  },
116
- "gitHead": "a2cbdad9f8dcc376f2098d217485525953b64cd9"
118
+ "gitHead": "0fd557e03e51d93231c063f9145ec0ff0746c935"
117
119
  }