@mpxjs/webpack-plugin 2.10.13-beta.2 → 2.10.14-beta.1

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/index.js CHANGED
@@ -1880,92 +1880,72 @@ try {
1880
1880
  normalModuleFactory.hooks.afterResolve.tap('MpxWebpackPlugin', ({ createData }) => {
1881
1881
  const { queryObj } = parseRequest(createData.request)
1882
1882
  const loaders = createData.loaders
1883
- const type = queryObj.type
1884
- const mpxProcessFlag = queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG
1885
- const vueProcessFlag = queryObj.vue && queryObj.mpx !== MPX_PROCESSED_FLAG
1886
- if (mpxProcessFlag || vueProcessFlag) {
1883
+ if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
1884
+ const type = queryObj.type
1887
1885
  const extract = queryObj.extract
1888
- if (type === 'styles' || type === 'style') {
1889
- const loaderTypes = {
1890
- 'node_modules/stylus-loader': -1,
1891
- 'node_modules/sass-loader': -1,
1892
- 'node_modules/less-loader': -1,
1893
- 'node_modules/css-loader': -1
1894
- }
1886
+
1887
+ if (type === 'styles') {
1888
+ let insertBeforeIndex = -1
1889
+ // 单次遍历收集所有索引
1895
1890
  loaders.forEach((loader, index) => {
1896
1891
  const currentLoader = toPosix(loader.loader)
1897
- for (const key in loaderTypes) {
1898
- if (currentLoader.includes(key)) {
1899
- loaderTypes[key] = index
1900
- break
1901
- }
1892
+ if (currentLoader.includes('node_modules/stylus-loader') || currentLoader.includes('node_modules/sass-loader') || currentLoader.includes('node_modules/less-loader')) {
1893
+ insertBeforeIndex = index
1902
1894
  }
1903
1895
  })
1904
- const insertStripLoaders = (index) => {
1905
- if (index !== -1) {
1906
- loaders.splice(index, 0, { loader: styleStripConditionalPath, options: {id: 0} })
1907
- loaders.splice(index + 2, 0, { loader: styleStripConditionalPath, options: {id: 1} })
1908
- return true
1909
- }
1910
- return false
1911
- }
1912
1896
 
1913
- const priorities = ['node_modules/stylus-loader', 'node_modules/less-loader', 'node_modules/sass-loader', 'node_modules/css-loader']
1914
- for (const loaderKey of priorities) {
1915
- if (insertStripLoaders(loaderTypes[loaderKey])) {
1916
- break
1917
- }
1897
+ if (insertBeforeIndex !== -1) {
1898
+ loaders.splice(insertBeforeIndex, 0, { loader: styleStripConditionalPath })
1918
1899
  }
1900
+ loaders.push({ loader: styleStripConditionalPath })
1919
1901
  }
1920
1902
 
1921
- if (mpxProcessFlag) {
1922
- switch (type) {
1923
- case 'styles':
1924
- case 'template': {
1925
- let insertBeforeIndex = -1
1926
- const info = typeLoaderProcessInfo[type]
1927
- loaders.forEach((loader, index) => {
1928
- const currentLoader = toPosix(loader.loader)
1929
- if (currentLoader.includes(info[0])) {
1930
- loader.loader = info[1]
1931
- insertBeforeIndex = index
1932
- } else if (currentLoader.includes(info[1])) {
1933
- insertBeforeIndex = index
1934
- }
1935
- })
1936
- if (insertBeforeIndex > -1) {
1937
- loaders.splice(insertBeforeIndex + 1, 0, {
1938
- loader: info[2]
1939
- })
1903
+ switch (type) {
1904
+ case 'styles':
1905
+ case 'template': {
1906
+ let insertBeforeIndex = -1
1907
+ const info = typeLoaderProcessInfo[type]
1908
+ loaders.forEach((loader, index) => {
1909
+ const currentLoader = toPosix(loader.loader)
1910
+ if (currentLoader.includes(info[0])) {
1911
+ loader.loader = info[1]
1912
+ insertBeforeIndex = index
1913
+ } else if (currentLoader.includes(info[1])) {
1914
+ insertBeforeIndex = index
1940
1915
  }
1941
- break
1916
+ })
1917
+ if (insertBeforeIndex > -1) {
1918
+ loaders.splice(insertBeforeIndex + 1, 0, {
1919
+ loader: info[2]
1920
+ })
1942
1921
  }
1943
- case 'json':
1944
- if (queryObj.isTheme) {
1945
- loaders.unshift({
1946
- loader: jsonThemeCompilerPath
1947
- })
1948
- } else if (queryObj.isPlugin) {
1949
- loaders.unshift({
1950
- loader: jsonPluginCompilerPath
1951
- })
1952
- } else {
1953
- loaders.unshift({
1954
- loader: jsonCompilerPath
1955
- })
1956
- }
1957
- break
1958
- case 'wxs':
1922
+ break
1923
+ }
1924
+ case 'json':
1925
+ if (queryObj.isTheme) {
1959
1926
  loaders.unshift({
1960
- loader: wxsLoaderPath
1927
+ loader: jsonThemeCompilerPath
1961
1928
  })
1962
- break
1963
- }
1964
- if (extract) {
1929
+ } else if (queryObj.isPlugin) {
1930
+ loaders.unshift({
1931
+ loader: jsonPluginCompilerPath
1932
+ })
1933
+ } else {
1934
+ loaders.unshift({
1935
+ loader: jsonCompilerPath
1936
+ })
1937
+ }
1938
+ break
1939
+ case 'wxs':
1965
1940
  loaders.unshift({
1966
- loader: extractorPath
1941
+ loader: wxsLoaderPath
1967
1942
  })
1968
- }
1943
+ break
1944
+ }
1945
+ if (extract) {
1946
+ loaders.unshift({
1947
+ loader: extractorPath
1948
+ })
1969
1949
  }
1970
1950
  createData.resource = addQuery(createData.resource, { mpx: MPX_PROCESSED_FLAG }, true)
1971
1951
  }
@@ -662,7 +662,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
662
662
  const moveDistance = e[strAbso] - preAbsolutePos.value;
663
663
  const eventData = {
664
664
  translation: moveDistance,
665
- transdir: moveDistance !== 0 ? moveDistance : e[strAbso] - moveTranstion.value
665
+ transdir: moveDistance
666
666
  };
667
667
  // 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
668
668
  const { half } = computeHalf(eventData);
@@ -203,16 +203,13 @@ function backgroundSize(imageProps, preImageInfo, imageSize, layoutInfo) {
203
203
  else { // 数值类型 ImageStyle
204
204
  // 数值类型设置为 stretch
205
205
  imageProps.resizeMode = 'stretch';
206
- if (type === 'linear') {
207
- const dimensionWidth = calcPercent(width, layoutWidth) || 0;
208
- const dimensionHeight = calcPercent(height, layoutHeight) || 0;
209
- // ios 上 linear 组件只要重新触发渲染,在渲染过程中 width 或者 height 被设置为 0,即使后面再更新为正常宽高,也会渲染不出来
210
- if (dimensionWidth && dimensionHeight) {
211
- dimensions = {
212
- width: dimensionWidth,
213
- height: dimensionHeight
214
- };
215
- }
206
+ if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
207
+ // ios linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
208
+ // 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
209
+ dimensions = {
210
+ width: 0,
211
+ height: 0
212
+ };
216
213
  }
217
214
  else {
218
215
  dimensions = {
@@ -755,7 +755,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
755
755
  const moveDistance = e[strAbso] - preAbsolutePos.value
756
756
  const eventData = {
757
757
  translation: moveDistance,
758
- transdir: moveDistance !== 0 ? moveDistance : e[strAbso] - moveTranstion.value
758
+ transdir: moveDistance
759
759
  }
760
760
  // 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
761
761
  const { half } = computeHalf(eventData)
@@ -287,16 +287,13 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
287
287
  } else { // 数值类型 ImageStyle
288
288
  // 数值类型设置为 stretch
289
289
  imageProps.resizeMode = 'stretch'
290
- if (type === 'linear') {
291
- const dimensionWidth = calcPercent(width as NumberVal, layoutWidth) || 0
292
- const dimensionHeight = calcPercent(height as NumberVal, layoutHeight) || 0
293
- // ios 上 linear 组件只要重新触发渲染,在渲染过程中 width 或者 height 被设置为 0,即使后面再更新为正常宽高,也会渲染不出来
294
- if (dimensionWidth && dimensionHeight) {
295
- dimensions = {
296
- width: dimensionWidth,
297
- height: dimensionHeight
298
- } as { width: NumberVal, height: NumberVal }
299
- }
290
+ if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
291
+ // ios linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
292
+ // 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
293
+ dimensions = {
294
+ width: 0,
295
+ height: 0
296
+ } as { width: NumberVal, height: NumberVal }
300
297
  } else {
301
298
  dimensions = {
302
299
  width: isPercent(width) ? width : +width,
@@ -56,19 +56,7 @@
56
56
  if (val !== -1) this.setSelectionRange(undefined, val)
57
57
  },
58
58
  immediate: true
59
- },
60
- focus (val) {
61
- if (val) {
62
- this.$nextTick(() => {
63
- this.$refs.input.focus()
64
- })
65
- } else {
66
- this.$nextTick(() => {
67
- this.$refs.input.blur()
68
- })
69
- }
70
- },
71
- immediate: true
59
+ }
72
60
  },
73
61
  render (createElement) {
74
62
  const mergeBefore = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.13-beta.2",
3
+ "version": "2.10.14-beta.1",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"