Przeglądaj źródła

chore: enable wechat lazy code loading

Developer 4 tygodni temu
rodzic
commit
c072802c26
2 zmienionych plików z 14 dodań i 1 usunięć
  1. 2 1
      manifest.json
  2. 12 0
      tests/wechat-lazy-code-loading.test.js

+ 2 - 1
manifest.json

@@ -53,7 +53,8 @@
         "appid" : "wxb412ad17f77c75c6",
         "setting" : {
             "urlCheck" : false,
-            "minified" : true
+            "minified" : true,
+            "lazyCodeLoading" : "requiredComponents"
         },
         "permission" : {
             "scope.writePhotosAlbum" : {

+ 12 - 0
tests/wechat-lazy-code-loading.test.js

@@ -0,0 +1,12 @@
+import assert from 'node:assert/strict'
+import fs from 'node:fs'
+import path from 'node:path'
+import test from 'node:test'
+
+const manifestFile = path.resolve('manifest.json')
+
+test('微信小程序启用自定义组件按需注入', () => {
+  const source = fs.readFileSync(manifestFile, 'utf8')
+
+  assert.match(source, /"mp-weixin"\s*:\s*\{[\s\S]*?"setting"\s*:\s*\{[\s\S]*?"lazyCodeLoading"\s*:\s*"requiredComponents"/)
+})