@dimina/compiler 1.0.16 → 1.1.0

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/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  ### 安装
10
10
 
11
+ 运行环境要求 Node.js 20 或更高版本。
12
+
11
13
  ```sh
12
14
  npm install @dimina/compiler -g
13
15
  ```
@@ -126,6 +128,27 @@ miniprogram_npm/ -> npm包构建 (npm组件支持)
126
128
 
127
129
  详细使用说明请参考:[TypeScript、Less 和 SCSS 支持文档](./docs/typescript-less-scss-support.md)
128
130
 
131
+ ### 自定义文件类型(custom file types)
132
+
133
+ 编译器内置识别 `wx*`(`.wxml/.wxss/.wxs`)与 `dd*`(`.ddml/.ddss`)系扩展名。通过编程入口 `build()` 的 `options.fileTypes`,可在内置之上**追加**自定义品牌扩展名(如 `.qdml/.qdss/.qds`),使其与对应内置类型等价编译:
134
+
135
+ ```js
136
+ import build from '@dimina/compiler'
137
+
138
+ await build(targetPath, workPath, true, {
139
+ fileTypes: {
140
+ template: ['qdml'], // 追加模板扩展名,与 .wxml/.ddml 等价 -> view.js
141
+ style: ['qdss'], // 追加样式扩展名,与 .wxss/.ddss 等价 -> style.css
142
+ viewScript: ['qds'], // 追加 WXS 类视图脚本:同时覆盖 .qds 文件与内联 <qds> 标签
143
+ },
144
+ })
145
+ ```
146
+
147
+ - 自动归一化:补前导点、转小写、去重;内置项在前、自定义项在后即查找优先级。
148
+ - 内置 `wx`/`dd` 系永远保留,仅追加不替换。
149
+ - `viewScript` 同时作用于**文件扩展名**(`.qds`)与**内联标签**(`<qds module>`)。
150
+ - CLI 暂未开放对应 flag,自定义文件类型能力通过编程入口注入。
151
+
129
152
  ### npm 组件支持
130
153
 
131
154
  编译器现已支持微信小程序的 npm 包功能,遵循微信官方的 npm 支持规范:
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- const require_env = require("../env-Dmnqp9bD.cjs");
2
+ const require_rolldown_runtime = require("../rolldown-runtime-D6vf50IK.cjs");
3
3
  const require_index = require("../index.cjs");
4
4
  let node_path = require("node:path");
5
- node_path = require_env.__toESM(node_path, 1);
5
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
6
6
  let node_process = require("node:process");
7
- node_process = require_env.__toESM(node_process, 1);
7
+ node_process = require_rolldown_runtime.__toESM(node_process, 1);
8
8
  let chokidar = require("chokidar");
9
- chokidar = require_env.__toESM(chokidar, 1);
9
+ chokidar = require_rolldown_runtime.__toESM(chokidar, 1);
10
10
  let commander = require("commander");
11
11
  var package_default = {
12
12
  name: "@dimina/compiler",
13
- version: "1.0.16",
13
+ version: "1.1.0",
14
14
  description: "星河编译工具",
15
15
  main: "./dist/index.cjs",
16
16
  module: "./dist/index.js",
@@ -49,6 +49,7 @@ var package_default = {
49
49
  },
50
50
  author: "doslin",
51
51
  license: "Apache-2.0",
52
+ engines: { "node": ">=20" },
52
53
  keywords: [
53
54
  "dimina",
54
55
  "compiler",
@@ -57,22 +58,23 @@ var package_default = {
57
58
  "星河"
58
59
  ],
59
60
  dependencies: {
60
- "@vue/compiler-sfc": "^3.5.34",
61
- "autoprefixer": "^10.5.0",
61
+ "@vue/compiler-sfc": "^3.5.39",
62
+ "@vue/shared": "^3.5.39",
63
+ "autoprefixer": "^10.5.3",
62
64
  "cheerio": "^1.2.0",
63
65
  "chokidar": "^4.0.3",
64
66
  "commander": "^14.0.3",
65
- "cssnano": "^8.0.1",
66
- "esbuild": "^0.28.0",
67
+ "cssnano": "^8.0.2",
68
+ "esbuild": "^0.28.1",
67
69
  "htmlparser2": "^12.0.0",
68
- "less": "^4.6.4",
70
+ "less": "^4.6.7",
69
71
  "listr2": "^9.0.5",
70
72
  "magic-string": "^0.30.21",
71
- "oxc-parser": "^0.129.0",
72
- "oxc-walker": "^0.7.0",
73
- "postcss": "^8.5.14",
74
- "postcss-selector-parser": "^7.1.1",
75
- "sass": "^1.99.0",
73
+ "oxc-parser": "^0.139.0",
74
+ "oxc-walker": "^1.0.0",
75
+ "postcss": "^8.5.19",
76
+ "postcss-selector-parser": "^7.1.4",
77
+ "sass": "^1.101.0",
76
78
  "source-map-js": "^1.2.1"
77
79
  },
78
80
  publishConfig: {
package/dist/bin/index.js CHANGED
@@ -6,7 +6,7 @@ import chokidar from "chokidar";
6
6
  import { program } from "commander";
7
7
  var package_default = {
8
8
  name: "@dimina/compiler",
9
- version: "1.0.16",
9
+ version: "1.1.0",
10
10
  description: "星河编译工具",
11
11
  main: "./dist/index.cjs",
12
12
  module: "./dist/index.js",
@@ -45,6 +45,7 @@ var package_default = {
45
45
  },
46
46
  author: "doslin",
47
47
  license: "Apache-2.0",
48
+ engines: { "node": ">=20" },
48
49
  keywords: [
49
50
  "dimina",
50
51
  "compiler",
@@ -53,22 +54,23 @@ var package_default = {
53
54
  "星河"
54
55
  ],
55
56
  dependencies: {
56
- "@vue/compiler-sfc": "^3.5.34",
57
- "autoprefixer": "^10.5.0",
57
+ "@vue/compiler-sfc": "^3.5.39",
58
+ "@vue/shared": "^3.5.39",
59
+ "autoprefixer": "^10.5.3",
58
60
  "cheerio": "^1.2.0",
59
61
  "chokidar": "^4.0.3",
60
62
  "commander": "^14.0.3",
61
- "cssnano": "^8.0.1",
62
- "esbuild": "^0.28.0",
63
+ "cssnano": "^8.0.2",
64
+ "esbuild": "^0.28.1",
63
65
  "htmlparser2": "^12.0.0",
64
- "less": "^4.6.4",
66
+ "less": "^4.6.7",
65
67
  "listr2": "^9.0.5",
66
68
  "magic-string": "^0.30.21",
67
- "oxc-parser": "^0.129.0",
68
- "oxc-walker": "^0.7.0",
69
- "postcss": "^8.5.14",
70
- "postcss-selector-parser": "^7.1.1",
71
- "sass": "^1.99.0",
69
+ "oxc-parser": "^0.139.0",
70
+ "oxc-walker": "^1.0.0",
71
+ "postcss": "^8.5.19",
72
+ "postcss-selector-parser": "^7.1.4",
73
+ "sass": "^1.101.0",
72
74
  "source-map-js": "^1.2.1"
73
75
  },
74
76
  publishConfig: {
@@ -1,9 +1,12 @@
1
- require("./env-Dmnqp9bD.cjs");
1
+ const require_env = require("./env-B4U3zZUm.cjs");
2
+ let node_worker_threads = require("node:worker_threads");
2
3
  let htmlparser2 = require("htmlparser2");
4
+ let _vue_shared = require("@vue/shared");
3
5
  //#region src/common/compatibility-reference.js
4
6
  var supportedBuiltinComponents = [
5
7
  "block",
6
8
  "button",
9
+ "canvas",
7
10
  "checkbox",
8
11
  "checkbox-group",
9
12
  "cover-image",
@@ -43,12 +46,46 @@ var supportedBuiltinComponents = [
43
46
  var supportedWxApis = [
44
47
  "env",
45
48
  "canIUse",
49
+ "getUpdateManager",
46
50
  "openSystemBluetoothSetting",
47
51
  "getWindowInfo",
48
52
  "getSystemSetting",
49
53
  "getSystemInfoSync",
50
54
  "getSystemInfoAsync",
51
55
  "getSystemInfo",
56
+ "getAppBaseInfo",
57
+ "getDeviceInfo",
58
+ "onThemeChange",
59
+ "offThemeChange",
60
+ "openBluetoothAdapter",
61
+ "closeBluetoothAdapter",
62
+ "getBluetoothAdapterState",
63
+ "startBluetoothDevicesDiscovery",
64
+ "stopBluetoothDevicesDiscovery",
65
+ "getBluetoothDevices",
66
+ "getConnectedBluetoothDevices",
67
+ "onBluetoothAdapterStateChange",
68
+ "offBluetoothAdapterStateChange",
69
+ "onBluetoothDeviceFound",
70
+ "offBluetoothDeviceFound",
71
+ "createBLEConnection",
72
+ "closeBLEConnection",
73
+ "getBLEDeviceServices",
74
+ "getBLEDeviceCharacteristics",
75
+ "readBLECharacteristicValue",
76
+ "writeBLECharacteristicValue",
77
+ "notifyBLECharacteristicValueChange",
78
+ "getBLEDeviceRSSI",
79
+ "setBLEMTU",
80
+ "getBLEMTU",
81
+ "onBLEConnectionStateChange",
82
+ "offBLEConnectionStateChange",
83
+ "onBLECharacteristicValueChange",
84
+ "offBLECharacteristicValueChange",
85
+ "onBLEMTUChange",
86
+ "offBLEMTUChange",
87
+ "isBluetoothDevicePaired",
88
+ "makeBluetoothPair",
52
89
  "reLaunch",
53
90
  "redirectTo",
54
91
  "navigateTo",
@@ -63,12 +100,58 @@ var supportedWxApis = [
63
100
  "setNavigationBarColor",
64
101
  "pageScrollTo",
65
102
  "getMenuButtonBoundingClientRect",
103
+ "onMenuButtonBoundingClientRectWeightChange",
104
+ "offMenuButtonBoundingClientRectWeightChange",
105
+ "nextTick",
66
106
  "createAnimation",
107
+ "createCanvasContext",
108
+ "createOffscreenCanvas",
109
+ "canvasToTempFilePath",
67
110
  "createSelectorQuery",
68
111
  "createIntersectionObserver",
69
112
  "request",
70
113
  "downloadFile",
71
114
  "uploadFile",
115
+ "startLocalServiceDiscovery",
116
+ "stopLocalServiceDiscovery",
117
+ "onLocalServiceDiscoveryStop",
118
+ "offLocalServiceDiscoveryStop",
119
+ "onLocalServiceFound",
120
+ "offLocalServiceFound",
121
+ "onLocalServiceLost",
122
+ "offLocalServiceLost",
123
+ "onLocalServiceResolveFail",
124
+ "offLocalServiceResolveFail",
125
+ "createUDPSocket",
126
+ "UDPSocket.bind",
127
+ "UDPSocket.close",
128
+ "UDPSocket.connect",
129
+ "UDPSocket.send",
130
+ "UDPSocket.write",
131
+ "UDPSocket.setTTL",
132
+ "UDPSocket.onClose",
133
+ "UDPSocket.offClose",
134
+ "UDPSocket.onError",
135
+ "UDPSocket.offError",
136
+ "UDPSocket.onListening",
137
+ "UDPSocket.offListening",
138
+ "UDPSocket.onMessage",
139
+ "UDPSocket.offMessage",
140
+ "createTCPSocket",
141
+ "TCPSocket.bindWifi",
142
+ "TCPSocket.close",
143
+ "TCPSocket.connect",
144
+ "TCPSocket.write",
145
+ "TCPSocket.onBindWifi",
146
+ "TCPSocket.offBindWifi",
147
+ "TCPSocket.onClose",
148
+ "TCPSocket.offClose",
149
+ "TCPSocket.onConnect",
150
+ "TCPSocket.offConnect",
151
+ "TCPSocket.onError",
152
+ "TCPSocket.offError",
153
+ "TCPSocket.onMessage",
154
+ "TCPSocket.offMessage",
72
155
  "setStorageSync",
73
156
  "getStorageSync",
74
157
  "removeStorageSync",
@@ -101,6 +184,7 @@ var supportedWxApis = [
101
184
  //#region src/common/compatibility.js
102
185
  var cachedReference = null;
103
186
  var warnedItems = /* @__PURE__ */ new Set();
187
+ var pendingWarnings = [];
104
188
  function loadReference() {
105
189
  if (cachedReference) return cachedReference;
106
190
  cachedReference = {
@@ -124,7 +208,8 @@ function warnUnsupportedWxApi(apiName, filePath, line) {
124
208
  }
125
209
  function warnUnsupportedComponent(tagName, filePath, line) {
126
210
  const { supportedBuiltinComponents } = loadReference();
127
- if (!tagName || supportedBuiltinComponents.has(tagName)) return;
211
+ if (!tagName || supportedBuiltinComponents.has(tagName) || require_env.tagWhiteList.includes(tagName) || require_env.getViewScriptTags().includes(tagName)) return;
212
+ if (!require_env.miniProgramBuiltinTags.has(tagName) && (0, _vue_shared.isHTMLTag)(tagName)) return;
128
213
  const location = formatLocation(filePath, line);
129
214
  warnOnce("component", tagName, location, `[compat] Unsupported or undeclared component: <${tagName}>${location}`);
130
215
  }
@@ -136,7 +221,7 @@ function checkTemplateCompatibility(content, filePath, components = {}) {
136
221
  warnUnsupportedComponent(tagName, filePath, getLineByIndex(content, parser.startIndex));
137
222
  },
138
223
  onerror(error) {
139
- console.warn("[compat]", `Failed to parse template for compatibility diagnostics: ${filePath}`, error.message);
224
+ warnOnce("parse", filePath, error.message, `[compat] Failed to parse template for compatibility diagnostics: ${filePath} ${error.message}`);
140
225
  }
141
226
  }, {
142
227
  xmlMode: true,
@@ -161,7 +246,11 @@ function warnOnce(type, name, location, message) {
161
246
  const key = `${type}:${name}:${location}`;
162
247
  if (warnedItems.has(key)) return;
163
248
  warnedItems.add(key);
164
- console.warn(message);
249
+ if (node_worker_threads.isMainThread) console.warn(message);
250
+ else pendingWarnings.push(message);
251
+ }
252
+ function takeCompatibilityWarnings() {
253
+ return pendingWarnings.splice(0);
165
254
  }
166
255
  //#endregion
167
256
  Object.defineProperty(exports, "checkTemplateCompatibility", {
@@ -176,6 +265,12 @@ Object.defineProperty(exports, "getWxMemberName", {
176
265
  return getWxMemberName;
177
266
  }
178
267
  });
268
+ Object.defineProperty(exports, "takeCompatibilityWarnings", {
269
+ enumerable: true,
270
+ get: function() {
271
+ return takeCompatibilityWarnings;
272
+ }
273
+ });
179
274
  Object.defineProperty(exports, "warnUnsupportedWxApi", {
180
275
  enumerable: true,
181
276
  get: function() {
@@ -1,8 +1,12 @@
1
+ import { C as tagWhiteList, S as miniProgramBuiltinTags, m as getViewScriptTags } from "./env-OH3--qg8.js";
2
+ import { isMainThread } from "node:worker_threads";
1
3
  import { Parser } from "htmlparser2";
4
+ import { isHTMLTag } from "@vue/shared";
2
5
  //#region src/common/compatibility-reference.js
3
6
  var supportedBuiltinComponents = [
4
7
  "block",
5
8
  "button",
9
+ "canvas",
6
10
  "checkbox",
7
11
  "checkbox-group",
8
12
  "cover-image",
@@ -42,12 +46,46 @@ var supportedBuiltinComponents = [
42
46
  var supportedWxApis = [
43
47
  "env",
44
48
  "canIUse",
49
+ "getUpdateManager",
45
50
  "openSystemBluetoothSetting",
46
51
  "getWindowInfo",
47
52
  "getSystemSetting",
48
53
  "getSystemInfoSync",
49
54
  "getSystemInfoAsync",
50
55
  "getSystemInfo",
56
+ "getAppBaseInfo",
57
+ "getDeviceInfo",
58
+ "onThemeChange",
59
+ "offThemeChange",
60
+ "openBluetoothAdapter",
61
+ "closeBluetoothAdapter",
62
+ "getBluetoothAdapterState",
63
+ "startBluetoothDevicesDiscovery",
64
+ "stopBluetoothDevicesDiscovery",
65
+ "getBluetoothDevices",
66
+ "getConnectedBluetoothDevices",
67
+ "onBluetoothAdapterStateChange",
68
+ "offBluetoothAdapterStateChange",
69
+ "onBluetoothDeviceFound",
70
+ "offBluetoothDeviceFound",
71
+ "createBLEConnection",
72
+ "closeBLEConnection",
73
+ "getBLEDeviceServices",
74
+ "getBLEDeviceCharacteristics",
75
+ "readBLECharacteristicValue",
76
+ "writeBLECharacteristicValue",
77
+ "notifyBLECharacteristicValueChange",
78
+ "getBLEDeviceRSSI",
79
+ "setBLEMTU",
80
+ "getBLEMTU",
81
+ "onBLEConnectionStateChange",
82
+ "offBLEConnectionStateChange",
83
+ "onBLECharacteristicValueChange",
84
+ "offBLECharacteristicValueChange",
85
+ "onBLEMTUChange",
86
+ "offBLEMTUChange",
87
+ "isBluetoothDevicePaired",
88
+ "makeBluetoothPair",
51
89
  "reLaunch",
52
90
  "redirectTo",
53
91
  "navigateTo",
@@ -62,12 +100,58 @@ var supportedWxApis = [
62
100
  "setNavigationBarColor",
63
101
  "pageScrollTo",
64
102
  "getMenuButtonBoundingClientRect",
103
+ "onMenuButtonBoundingClientRectWeightChange",
104
+ "offMenuButtonBoundingClientRectWeightChange",
105
+ "nextTick",
65
106
  "createAnimation",
107
+ "createCanvasContext",
108
+ "createOffscreenCanvas",
109
+ "canvasToTempFilePath",
66
110
  "createSelectorQuery",
67
111
  "createIntersectionObserver",
68
112
  "request",
69
113
  "downloadFile",
70
114
  "uploadFile",
115
+ "startLocalServiceDiscovery",
116
+ "stopLocalServiceDiscovery",
117
+ "onLocalServiceDiscoveryStop",
118
+ "offLocalServiceDiscoveryStop",
119
+ "onLocalServiceFound",
120
+ "offLocalServiceFound",
121
+ "onLocalServiceLost",
122
+ "offLocalServiceLost",
123
+ "onLocalServiceResolveFail",
124
+ "offLocalServiceResolveFail",
125
+ "createUDPSocket",
126
+ "UDPSocket.bind",
127
+ "UDPSocket.close",
128
+ "UDPSocket.connect",
129
+ "UDPSocket.send",
130
+ "UDPSocket.write",
131
+ "UDPSocket.setTTL",
132
+ "UDPSocket.onClose",
133
+ "UDPSocket.offClose",
134
+ "UDPSocket.onError",
135
+ "UDPSocket.offError",
136
+ "UDPSocket.onListening",
137
+ "UDPSocket.offListening",
138
+ "UDPSocket.onMessage",
139
+ "UDPSocket.offMessage",
140
+ "createTCPSocket",
141
+ "TCPSocket.bindWifi",
142
+ "TCPSocket.close",
143
+ "TCPSocket.connect",
144
+ "TCPSocket.write",
145
+ "TCPSocket.onBindWifi",
146
+ "TCPSocket.offBindWifi",
147
+ "TCPSocket.onClose",
148
+ "TCPSocket.offClose",
149
+ "TCPSocket.onConnect",
150
+ "TCPSocket.offConnect",
151
+ "TCPSocket.onError",
152
+ "TCPSocket.offError",
153
+ "TCPSocket.onMessage",
154
+ "TCPSocket.offMessage",
71
155
  "setStorageSync",
72
156
  "getStorageSync",
73
157
  "removeStorageSync",
@@ -100,6 +184,7 @@ var supportedWxApis = [
100
184
  //#region src/common/compatibility.js
101
185
  var cachedReference = null;
102
186
  var warnedItems = /* @__PURE__ */ new Set();
187
+ var pendingWarnings = [];
103
188
  function loadReference() {
104
189
  if (cachedReference) return cachedReference;
105
190
  cachedReference = {
@@ -123,7 +208,8 @@ function warnUnsupportedWxApi(apiName, filePath, line) {
123
208
  }
124
209
  function warnUnsupportedComponent(tagName, filePath, line) {
125
210
  const { supportedBuiltinComponents } = loadReference();
126
- if (!tagName || supportedBuiltinComponents.has(tagName)) return;
211
+ if (!tagName || supportedBuiltinComponents.has(tagName) || tagWhiteList.includes(tagName) || getViewScriptTags().includes(tagName)) return;
212
+ if (!miniProgramBuiltinTags.has(tagName) && isHTMLTag(tagName)) return;
127
213
  const location = formatLocation(filePath, line);
128
214
  warnOnce("component", tagName, location, `[compat] Unsupported or undeclared component: <${tagName}>${location}`);
129
215
  }
@@ -135,7 +221,7 @@ function checkTemplateCompatibility(content, filePath, components = {}) {
135
221
  warnUnsupportedComponent(tagName, filePath, getLineByIndex(content, parser.startIndex));
136
222
  },
137
223
  onerror(error) {
138
- console.warn("[compat]", `Failed to parse template for compatibility diagnostics: ${filePath}`, error.message);
224
+ warnOnce("parse", filePath, error.message, `[compat] Failed to parse template for compatibility diagnostics: ${filePath} ${error.message}`);
139
225
  }
140
226
  }, {
141
227
  xmlMode: true,
@@ -160,7 +246,11 @@ function warnOnce(type, name, location, message) {
160
246
  const key = `${type}:${name}:${location}`;
161
247
  if (warnedItems.has(key)) return;
162
248
  warnedItems.add(key);
163
- console.warn(message);
249
+ if (isMainThread) console.warn(message);
250
+ else pendingWarnings.push(message);
251
+ }
252
+ function takeCompatibilityWarnings() {
253
+ return pendingWarnings.splice(0);
164
254
  }
165
255
  //#endregion
166
- export { getWxMemberName as n, warnUnsupportedWxApi as r, checkTemplateCompatibility as t };
256
+ export { warnUnsupportedWxApi as i, getWxMemberName as n, takeCompatibilityWarnings as r, checkTemplateCompatibility as t };
@@ -1,14 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_env = require("../env-Dmnqp9bD.cjs");
3
- const require_compatibility = require("../compatibility-DlYbbw0F.cjs");
2
+ const require_rolldown_runtime = require("../rolldown-runtime-D6vf50IK.cjs");
3
+ const require_env = require("../env-B4U3zZUm.cjs");
4
+ const require_compatibility = require("../compatibility-CzIJUgPs.cjs");
4
5
  let node_path = require("node:path");
5
6
  let node_worker_threads = require("node:worker_threads");
6
7
  let node_fs = require("node:fs");
7
- node_fs = require_env.__toESM(node_fs, 1);
8
+ node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
8
9
  let oxc_parser = require("oxc-parser");
9
10
  let oxc_walker = require("oxc-walker");
10
11
  let magic_string = require("magic-string");
11
- magic_string = require_env.__toESM(magic_string, 1);
12
+ magic_string = require_rolldown_runtime.__toESM(magic_string, 1);
12
13
  let esbuild = require("esbuild");
13
14
  let source_map_js = require("source-map-js");
14
15
  //#region src/core/sourcemap.js
@@ -119,7 +120,10 @@ if (!node_worker_threads.isMainThread) node_worker_threads.parentPort.on("messag
119
120
  }
120
121
  await writeCompileRes(mainCompileRes, null);
121
122
  processedModules.clear();
122
- node_worker_threads.parentPort.postMessage({ success: true });
123
+ node_worker_threads.parentPort.postMessage({
124
+ success: true,
125
+ compatibilityWarnings: require_compatibility.takeCompatibilityWarnings()
126
+ });
123
127
  } catch (error) {
124
128
  processedModules.clear();
125
129
  node_worker_threads.parentPort.postMessage({
@@ -167,18 +171,10 @@ async function compileJS(pages, root, mainCompileRes, progress) {
167
171
  }
168
172
  return compileRes;
169
173
  }
170
- async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
174
+ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, activePaths = /* @__PURE__ */ new Set(), putMain = false) {
171
175
  const currentPath = module.path;
172
- if (depthChain.includes(currentPath)) {
173
- console.warn("[logic]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
174
- return;
175
- }
176
- if (depthChain.length > 20) {
177
- console.warn("[logic]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
178
- return;
179
- }
180
- depthChain = [...depthChain, currentPath];
181
- if (!module.path) return;
176
+ if (!currentPath) return;
177
+ if (activePaths.has(currentPath)) return;
182
178
  if (require_env.hasCompileInfo(module.path, compileRes, mainCompileRes)) return;
183
179
  const compileInfo = {
184
180
  path: module.path,
@@ -208,6 +204,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
208
204
  }).program;
209
205
  const s = new magic_string.default(sourceCode);
210
206
  const extraInfo = { path: module.path };
207
+ activePaths.add(currentPath);
211
208
  if (module.component) extraInfo.component = true;
212
209
  if (module.usingComponents) {
213
210
  const componentsObj = {};
@@ -223,7 +220,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
223
220
  } else toMainSubPackage = false;
224
221
  const componentModule = require_env.getComponent(path);
225
222
  if (!componentModule) continue;
226
- await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, putMain || toMainSubPackage);
223
+ await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, activePaths, putMain || toMainSubPackage);
227
224
  componentsObj[name] = path;
228
225
  }
229
226
  extraInfo.usingComponents = componentsObj;
@@ -308,7 +305,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
308
305
  }
309
306
  }
310
307
  } });
311
- for (const depId of dependenciesToProcess) await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false, depthChain, putMain);
308
+ for (const depId of dependenciesToProcess) await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false, activePaths, putMain);
312
309
  for (const replacement of pathReplacements.reverse()) s.overwrite(replacement.start, replacement.end, `'${replacement.newValue}'`);
313
310
  const modifiedCode = s.toString();
314
311
  let preEsbuildMap = null;
@@ -344,6 +341,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
344
341
  compileInfo.code = modifiedCode;
345
342
  }
346
343
  processedModules.add(packageName + currentPath);
344
+ activePaths.delete(currentPath);
347
345
  }
348
346
  function isLocalAssetString(value) {
349
347
  return typeof value === "string" && !value.startsWith("http") && !value.startsWith("//") && (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) && /\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(value);
@@ -1,5 +1,5 @@
1
- import { a as getContentByPath, d as resetStoreInfo, f as resolveAppAlias, g as hasCompileInfo, i as getComponent, l as getTargetPath, m as collectAssets, n as getAppId, o as getNpmResolver, t as getAppConfigInfo, u as getWorkPath } from "../env-p9Az8lv5.js";
2
- import { n as getWxMemberName, r as warnUnsupportedWxApi } from "../compatibility-C_zWVjYl.js";
1
+ import { _ as resolveAppAlias, a as getComponent, d as getTargetPath, g as resetStoreInfo, h as getWorkPath, n as getAppId, o as getContentByPath, s as getNpmResolver, t as getAppConfigInfo, x as hasCompileInfo, y as collectAssets } from "../env-OH3--qg8.js";
2
+ import { i as warnUnsupportedWxApi, n as getWxMemberName, r as takeCompatibilityWarnings } from "../compatibility-DdxfVhcK.js";
3
3
  import { resolve, sep } from "node:path";
4
4
  import { isMainThread, parentPort } from "node:worker_threads";
5
5
  import fs from "node:fs";
@@ -116,7 +116,10 @@ if (!isMainThread) parentPort.on("message", async ({ pages, storeInfo, sourcemap
116
116
  }
117
117
  await writeCompileRes(mainCompileRes, null);
118
118
  processedModules.clear();
119
- parentPort.postMessage({ success: true });
119
+ parentPort.postMessage({
120
+ success: true,
121
+ compatibilityWarnings: takeCompatibilityWarnings()
122
+ });
120
123
  } catch (error) {
121
124
  processedModules.clear();
122
125
  parentPort.postMessage({
@@ -164,18 +167,10 @@ async function compileJS(pages, root, mainCompileRes, progress) {
164
167
  }
165
168
  return compileRes;
166
169
  }
167
- async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
170
+ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, activePaths = /* @__PURE__ */ new Set(), putMain = false) {
168
171
  const currentPath = module.path;
169
- if (depthChain.includes(currentPath)) {
170
- console.warn("[logic]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
171
- return;
172
- }
173
- if (depthChain.length > 20) {
174
- console.warn("[logic]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
175
- return;
176
- }
177
- depthChain = [...depthChain, currentPath];
178
- if (!module.path) return;
172
+ if (!currentPath) return;
173
+ if (activePaths.has(currentPath)) return;
179
174
  if (hasCompileInfo(module.path, compileRes, mainCompileRes)) return;
180
175
  const compileInfo = {
181
176
  path: module.path,
@@ -205,6 +200,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
205
200
  }).program;
206
201
  const s = new MagicString(sourceCode);
207
202
  const extraInfo = { path: module.path };
203
+ activePaths.add(currentPath);
208
204
  if (module.component) extraInfo.component = true;
209
205
  if (module.usingComponents) {
210
206
  const componentsObj = {};
@@ -220,7 +216,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
220
216
  } else toMainSubPackage = false;
221
217
  const componentModule = getComponent(path);
222
218
  if (!componentModule) continue;
223
- await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, putMain || toMainSubPackage);
219
+ await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, activePaths, putMain || toMainSubPackage);
224
220
  componentsObj[name] = path;
225
221
  }
226
222
  extraInfo.usingComponents = componentsObj;
@@ -305,7 +301,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
305
301
  }
306
302
  }
307
303
  } });
308
- for (const depId of dependenciesToProcess) await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false, depthChain, putMain);
304
+ for (const depId of dependenciesToProcess) await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false, activePaths, putMain);
309
305
  for (const replacement of pathReplacements.reverse()) s.overwrite(replacement.start, replacement.end, `'${replacement.newValue}'`);
310
306
  const modifiedCode = s.toString();
311
307
  let preEsbuildMap = null;
@@ -341,6 +337,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
341
337
  compileInfo.code = modifiedCode;
342
338
  }
343
339
  processedModules.add(packageName + currentPath);
340
+ activePaths.delete(currentPath);
344
341
  }
345
342
  function isLocalAssetString(value) {
346
343
  return typeof value === "string" && !value.startsWith("http") && !value.startsWith("//") && (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) && /\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(value);