@dimina-kit/compiler 0.0.2-dev.20260728080958 → 0.0.2-dev.20260728110120
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/dist/compile-core.browser.js +14975 -16294
- package/dist/compile-core.node-chunks/chunk-2VRS523Z.js +8 -0
- package/dist/compile-core.node-chunks/chunk-LUD2P6RM.js +211 -0
- package/dist/compile-core.node-chunks/{chunk-M62ZDT7T.js → chunk-QJ34C5KK.js} +66 -542
- package/dist/compile-core.node-chunks/{logic-compiler-AEZPY2MO.js → logic-compiler-2SQFOFEO.js} +113 -37
- package/dist/compile-core.node-chunks/style-compiler-ZEJ3XLTS.js +277 -0
- package/dist/compile-core.node-chunks/{view-compiler-2SMUHAPD.js → view-compiler-WQNV7H5G.js} +161 -425
- package/dist/compile-core.node.js +6 -11
- package/dist/pool.node-chunks/{chunk-CKQISGZS.js → chunk-7FGOYOXU.js} +66 -542
- package/dist/pool.node-chunks/chunk-C7GEIDCP.js +211 -0
- package/dist/pool.node-chunks/chunk-KLXXOLDF.js +8 -0
- package/dist/pool.node-chunks/{chunk-WX4462A5.js → chunk-PDHO4Y56.js} +6 -11
- package/dist/pool.node-chunks/{logic-compiler-P4T4OMTG.js → logic-compiler-BODAINZQ.js} +113 -37
- package/dist/pool.node-chunks/style-compiler-TUNDVSR5.js +277 -0
- package/dist/pool.node-chunks/{view-compiler-2D7HPYIN.js → view-compiler-HOFFL63K.js} +161 -425
- package/dist/pool.node.js +2 -2
- package/dist/stage-worker.browser.js +2156 -3475
- package/dist/stage-worker.node.js +2 -2
- package/package.json +4 -4
- package/dist/compile-core.node-chunks/chunk-23PCGQQU.js +0 -141
- package/dist/compile-core.node-chunks/chunk-QYHGF3MS.js +0 -1601
- package/dist/compile-core.node-chunks/style-compiler-4PHMBQIC.js +0 -470
- package/dist/pool.node-chunks/chunk-LGB3AH5C.js +0 -1601
- package/dist/pool.node-chunks/chunk-VHWKAXDL.js +0 -141
- package/dist/pool.node-chunks/style-compiler-W7EA2Y7R.js +0 -470
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getViewScriptTags
|
|
3
|
+
} from "./chunk-7FGOYOXU.js";
|
|
4
|
+
|
|
5
|
+
// ../../dimina/fe/packages/compiler/src/common/compatibility.js
|
|
6
|
+
import { Parser } from "htmlparser2";
|
|
7
|
+
|
|
8
|
+
// ../../dimina/fe/packages/compiler/src/common/compatibility-reference.js
|
|
9
|
+
var supportedBuiltinComponents = [
|
|
10
|
+
"block",
|
|
11
|
+
"button",
|
|
12
|
+
"canvas",
|
|
13
|
+
"checkbox",
|
|
14
|
+
"checkbox-group",
|
|
15
|
+
"cover-image",
|
|
16
|
+
"cover-view",
|
|
17
|
+
"form",
|
|
18
|
+
"icon",
|
|
19
|
+
"image",
|
|
20
|
+
"input",
|
|
21
|
+
"label",
|
|
22
|
+
"movable-area",
|
|
23
|
+
"movable-view",
|
|
24
|
+
"navigation-bar",
|
|
25
|
+
"navigator",
|
|
26
|
+
"picker",
|
|
27
|
+
"picker-view",
|
|
28
|
+
"picker-view-column",
|
|
29
|
+
"progress",
|
|
30
|
+
"radio",
|
|
31
|
+
"radio-group",
|
|
32
|
+
"rich-text",
|
|
33
|
+
"scroll-view",
|
|
34
|
+
"slider",
|
|
35
|
+
"slot",
|
|
36
|
+
"swiper",
|
|
37
|
+
"swiper-item",
|
|
38
|
+
"switch",
|
|
39
|
+
"template",
|
|
40
|
+
"text",
|
|
41
|
+
"textarea",
|
|
42
|
+
"video",
|
|
43
|
+
"view",
|
|
44
|
+
"web-view",
|
|
45
|
+
"wxs",
|
|
46
|
+
"include",
|
|
47
|
+
"import"
|
|
48
|
+
];
|
|
49
|
+
var supportedWxApis = [
|
|
50
|
+
"env",
|
|
51
|
+
"canIUse",
|
|
52
|
+
"getUpdateManager",
|
|
53
|
+
"openSystemBluetoothSetting",
|
|
54
|
+
"getWindowInfo",
|
|
55
|
+
"getSystemSetting",
|
|
56
|
+
"getSystemInfoSync",
|
|
57
|
+
"getSystemInfoAsync",
|
|
58
|
+
"getSystemInfo",
|
|
59
|
+
"reLaunch",
|
|
60
|
+
"redirectTo",
|
|
61
|
+
"navigateTo",
|
|
62
|
+
"navigateBack",
|
|
63
|
+
"showToast",
|
|
64
|
+
"showModal",
|
|
65
|
+
"showLoading",
|
|
66
|
+
"showActionSheet",
|
|
67
|
+
"hideToast",
|
|
68
|
+
"hideLoading",
|
|
69
|
+
"setNavigationBarTitle",
|
|
70
|
+
"setNavigationBarColor",
|
|
71
|
+
"pageScrollTo",
|
|
72
|
+
"getMenuButtonBoundingClientRect",
|
|
73
|
+
"createAnimation",
|
|
74
|
+
"createCanvasContext",
|
|
75
|
+
"createOffscreenCanvas",
|
|
76
|
+
"canvasToTempFilePath",
|
|
77
|
+
"createSelectorQuery",
|
|
78
|
+
"createIntersectionObserver",
|
|
79
|
+
"request",
|
|
80
|
+
"downloadFile",
|
|
81
|
+
"uploadFile",
|
|
82
|
+
"setStorageSync",
|
|
83
|
+
"getStorageSync",
|
|
84
|
+
"removeStorageSync",
|
|
85
|
+
"clearStorageSync",
|
|
86
|
+
"setStorage",
|
|
87
|
+
"getStorage",
|
|
88
|
+
"removeStorage",
|
|
89
|
+
"clearStorage",
|
|
90
|
+
"getStorageInfoSync",
|
|
91
|
+
"getStorageInfo",
|
|
92
|
+
"saveImageToPhotosAlbum",
|
|
93
|
+
"previewImage",
|
|
94
|
+
"compressImage",
|
|
95
|
+
"chooseImage",
|
|
96
|
+
"chooseMedia",
|
|
97
|
+
"chooseContact",
|
|
98
|
+
"addPhoneContact",
|
|
99
|
+
"setClipboardData",
|
|
100
|
+
"getClipboardData",
|
|
101
|
+
"vibrateShort",
|
|
102
|
+
"vibrateLong",
|
|
103
|
+
"hideKeyboard",
|
|
104
|
+
"getNetworkType",
|
|
105
|
+
"makePhoneCall",
|
|
106
|
+
"extBridge",
|
|
107
|
+
"extOnBridge",
|
|
108
|
+
"extOffBridge"
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
// ../../dimina/fe/packages/compiler/src/common/compatibility.js
|
|
112
|
+
var cachedReference = null;
|
|
113
|
+
var warnedItems = /* @__PURE__ */ new Set();
|
|
114
|
+
function loadReference() {
|
|
115
|
+
if (cachedReference) {
|
|
116
|
+
return cachedReference;
|
|
117
|
+
}
|
|
118
|
+
cachedReference = {
|
|
119
|
+
supportedBuiltinComponents: new Set(supportedBuiltinComponents),
|
|
120
|
+
supportedWxApis: new Set(supportedWxApis)
|
|
121
|
+
};
|
|
122
|
+
return cachedReference;
|
|
123
|
+
}
|
|
124
|
+
function getWxMemberName(node) {
|
|
125
|
+
if (node?.type !== "MemberExpression") {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
if (node.object?.type !== "Identifier" || node.object.name !== "wx") {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (!node.computed && node.property?.type === "Identifier") {
|
|
132
|
+
return node.property.name;
|
|
133
|
+
}
|
|
134
|
+
if (node.computed && (node.property?.type === "StringLiteral" || node.property?.type === "Literal") && typeof node.property.value === "string") {
|
|
135
|
+
return node.property.value;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
function warnUnsupportedWxApi(apiName, filePath, line) {
|
|
140
|
+
const { supportedWxApis: supportedWxApis2 } = loadReference();
|
|
141
|
+
if (!apiName || supportedWxApis2.has(apiName)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const location = formatLocation(filePath, line);
|
|
145
|
+
warnOnce("api", apiName, location, `[compat] Unsupported wx API: wx.${apiName}${location}`);
|
|
146
|
+
}
|
|
147
|
+
function warnUnsupportedComponent(tagName, filePath, line) {
|
|
148
|
+
const { supportedBuiltinComponents: supportedBuiltinComponents2 } = loadReference();
|
|
149
|
+
if (!tagName || supportedBuiltinComponents2.has(tagName) || getViewScriptTags().includes(tagName)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const location = formatLocation(filePath, line);
|
|
153
|
+
warnOnce("component", tagName, location, `[compat] Unsupported or undeclared component: <${tagName}>${location}`);
|
|
154
|
+
}
|
|
155
|
+
function checkTemplateCompatibility(content, filePath, components = {}) {
|
|
156
|
+
let parser;
|
|
157
|
+
parser = new Parser(
|
|
158
|
+
{
|
|
159
|
+
onopentag(tagName) {
|
|
160
|
+
if (components?.[tagName]) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const line = getLineByIndex(content, parser.startIndex);
|
|
164
|
+
warnUnsupportedComponent(tagName, filePath, line);
|
|
165
|
+
},
|
|
166
|
+
onerror(error) {
|
|
167
|
+
console.warn("[compat]", `Failed to parse template for compatibility diagnostics: ${filePath}`, error.message);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
xmlMode: true,
|
|
172
|
+
lowerCaseTags: false,
|
|
173
|
+
lowerCaseAttributeNames: false,
|
|
174
|
+
withStartIndices: true
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
parser.write(content);
|
|
178
|
+
parser.end();
|
|
179
|
+
}
|
|
180
|
+
function getLineByIndex(content, index) {
|
|
181
|
+
if (typeof index !== "number" || index < 0) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
let line = 1;
|
|
185
|
+
for (let i = 0; i < index; i++) {
|
|
186
|
+
if (content.charCodeAt(i) === 10) {
|
|
187
|
+
line++;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return line;
|
|
191
|
+
}
|
|
192
|
+
function formatLocation(filePath, line) {
|
|
193
|
+
if (!filePath) {
|
|
194
|
+
return "";
|
|
195
|
+
}
|
|
196
|
+
return line ? ` (${filePath}:${line})` : ` (${filePath})`;
|
|
197
|
+
}
|
|
198
|
+
function warnOnce(type, name, location, message) {
|
|
199
|
+
const key = `${type}:${name}:${location}`;
|
|
200
|
+
if (warnedItems.has(key)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
warnedItems.add(key);
|
|
204
|
+
console.warn(message);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
getWxMemberName,
|
|
209
|
+
warnUnsupportedWxApi,
|
|
210
|
+
checkTemplateCompatibility
|
|
211
|
+
};
|
|
@@ -12,21 +12,18 @@ import {
|
|
|
12
12
|
getViewScriptExts,
|
|
13
13
|
getWorkPath,
|
|
14
14
|
storeInfo
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7FGOYOXU.js";
|
|
16
16
|
|
|
17
17
|
// ../../dimina/fe/packages/compiler/src/common/publish.js
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
import process from "node:process";
|
|
20
20
|
import fs from "node:fs";
|
|
21
|
-
function createDist(
|
|
21
|
+
function createDist() {
|
|
22
22
|
const distPath = getTargetPath();
|
|
23
23
|
if (fs.existsSync(distPath)) {
|
|
24
24
|
fs.rmSync(distPath, { recursive: true, force: true });
|
|
25
25
|
}
|
|
26
26
|
fs.mkdirSync(distPath, { recursive: true });
|
|
27
|
-
if (seedPath && fs.existsSync(seedPath)) {
|
|
28
|
-
fs.cpSync(seedPath, distPath, { recursive: true });
|
|
29
|
-
}
|
|
30
27
|
}
|
|
31
28
|
function publishToDist(dist, useAppIdDir = true) {
|
|
32
29
|
const distPath = getTargetPath();
|
|
@@ -132,10 +129,9 @@ var config_compiler_default = compileConfig;
|
|
|
132
129
|
import fs3 from "node:fs";
|
|
133
130
|
import path2 from "node:path";
|
|
134
131
|
var NpmBuilder = class {
|
|
135
|
-
constructor(workPath, targetPath
|
|
132
|
+
constructor(workPath, targetPath) {
|
|
136
133
|
this.workPath = workPath;
|
|
137
134
|
this.targetPath = targetPath;
|
|
138
|
-
this.dependencyGraph = dependencyGraph;
|
|
139
135
|
this.builtPackages = /* @__PURE__ */ new Set();
|
|
140
136
|
this.packageDependencies = /* @__PURE__ */ new Map();
|
|
141
137
|
}
|
|
@@ -228,7 +224,6 @@ var NpmBuilder = class {
|
|
|
228
224
|
await this.copyPackageFiles(sourceItemPath, targetItemPath);
|
|
229
225
|
} else {
|
|
230
226
|
if (this.isMiniprogramFile(item.name)) {
|
|
231
|
-
this.dependencyGraph?.addFile("app", sourceItemPath, "config");
|
|
232
227
|
fs3.copyFileSync(sourceItemPath, targetItemPath);
|
|
233
228
|
}
|
|
234
229
|
}
|
|
@@ -323,9 +318,9 @@ var NpmBuilder = class {
|
|
|
323
318
|
|
|
324
319
|
// src/compile-core.js
|
|
325
320
|
var STAGE_IMPORTERS = {
|
|
326
|
-
logic: () => import("./logic-compiler-
|
|
327
|
-
view: () => import("./view-compiler-
|
|
328
|
-
style: () => import("./style-compiler-
|
|
321
|
+
logic: () => import("./logic-compiler-BODAINZQ.js"),
|
|
322
|
+
view: () => import("./view-compiler-HOFFL63K.js"),
|
|
323
|
+
style: () => import("./style-compiler-TUNDVSR5.js")
|
|
329
324
|
};
|
|
330
325
|
var stageLoads = /* @__PURE__ */ new Map();
|
|
331
326
|
var stageModules = /* @__PURE__ */ new Map();
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getWxMemberName,
|
|
3
|
-
takeCompatibilityWarnings,
|
|
4
3
|
warnUnsupportedWxApi
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-C7GEIDCP.js";
|
|
6
5
|
import {
|
|
7
6
|
isMainThread,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
remapSourcemap
|
|
11
|
-
} from "./chunk-VHWKAXDL.js";
|
|
7
|
+
parentPort
|
|
8
|
+
} from "./chunk-KLXXOLDF.js";
|
|
12
9
|
import {
|
|
13
10
|
collectAssets,
|
|
14
11
|
getAppConfigInfo,
|
|
15
12
|
getAppId,
|
|
16
13
|
getComponent,
|
|
17
14
|
getContentByPath,
|
|
18
|
-
getDependencyGraph,
|
|
19
15
|
getNpmResolver,
|
|
20
16
|
getTargetPath,
|
|
21
17
|
getWorkPath,
|
|
22
18
|
hasCompileInfo,
|
|
23
19
|
resetStoreInfo,
|
|
24
|
-
resolveAppAlias
|
|
25
|
-
|
|
26
|
-
} from "./chunk-CKQISGZS.js";
|
|
20
|
+
resolveAppAlias
|
|
21
|
+
} from "./chunk-7FGOYOXU.js";
|
|
27
22
|
|
|
28
23
|
// ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
|
|
29
24
|
import fs from "node:fs";
|
|
@@ -32,6 +27,102 @@ import { parseSync } from "oxc-parser";
|
|
|
32
27
|
import { walk } from "oxc-walker";
|
|
33
28
|
import MagicString from "magic-string";
|
|
34
29
|
import { transform } from "esbuild";
|
|
30
|
+
|
|
31
|
+
// ../../dimina/fe/packages/compiler/src/core/sourcemap.js
|
|
32
|
+
import { SourceMapConsumer, SourceMapGenerator } from "source-map-js";
|
|
33
|
+
function wrapModDefine(module) {
|
|
34
|
+
const code = module.code.endsWith("\n") ? module.code : module.code + "\n";
|
|
35
|
+
const extraLine = module.extraInfoCode || "";
|
|
36
|
+
const header = `modDefine('${module.path}', function(require, module, exports) {
|
|
37
|
+
${extraLine}`;
|
|
38
|
+
const footer = "});\n";
|
|
39
|
+
return { header, code, footer };
|
|
40
|
+
}
|
|
41
|
+
function mergeSourcemap(compileRes) {
|
|
42
|
+
const smg = new SourceMapGenerator({ file: "logic.js" });
|
|
43
|
+
let bundleCode = "";
|
|
44
|
+
let lineOffset = 0;
|
|
45
|
+
for (const module of compileRes) {
|
|
46
|
+
const { header, code, footer } = wrapModDefine(module);
|
|
47
|
+
bundleCode += header;
|
|
48
|
+
const headerLineCount = header.split("\n").length - 1;
|
|
49
|
+
lineOffset += headerLineCount;
|
|
50
|
+
if (module.map) {
|
|
51
|
+
const moduleMap = JSON.parse(module.map);
|
|
52
|
+
const smc = new SourceMapConsumer(moduleMap);
|
|
53
|
+
smc.eachMapping((mapping) => {
|
|
54
|
+
if (mapping.source == null) return;
|
|
55
|
+
smg.addMapping({
|
|
56
|
+
generated: {
|
|
57
|
+
line: mapping.generatedLine + lineOffset,
|
|
58
|
+
column: mapping.generatedColumn
|
|
59
|
+
},
|
|
60
|
+
original: {
|
|
61
|
+
line: mapping.originalLine,
|
|
62
|
+
column: mapping.originalColumn
|
|
63
|
+
},
|
|
64
|
+
source: mapping.source,
|
|
65
|
+
name: mapping.name
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
if (moduleMap.sourcesContent) {
|
|
69
|
+
moduleMap.sources.forEach((src, i) => {
|
|
70
|
+
smg.setSourceContent(src, moduleMap.sourcesContent[i]);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
bundleCode += code;
|
|
75
|
+
lineOffset += code.split("\n").length - 1;
|
|
76
|
+
bundleCode += footer;
|
|
77
|
+
lineOffset += footer.split("\n").length - 1;
|
|
78
|
+
}
|
|
79
|
+
return { bundleCode, sourcemap: smg.toString() };
|
|
80
|
+
}
|
|
81
|
+
function remapSourcemap(nextMap, prevMap) {
|
|
82
|
+
if (!nextMap) {
|
|
83
|
+
return prevMap;
|
|
84
|
+
}
|
|
85
|
+
if (!prevMap) {
|
|
86
|
+
return nextMap;
|
|
87
|
+
}
|
|
88
|
+
const nextMapObj = typeof nextMap === "string" ? JSON.parse(nextMap) : nextMap;
|
|
89
|
+
const prevMapObj = typeof prevMap === "string" ? JSON.parse(prevMap) : prevMap;
|
|
90
|
+
const smg = new SourceMapGenerator({ file: nextMapObj.file || prevMapObj.file || "" });
|
|
91
|
+
const prevSmc = new SourceMapConsumer(prevMapObj);
|
|
92
|
+
const nextSmc = new SourceMapConsumer(nextMapObj);
|
|
93
|
+
nextSmc.eachMapping((mapping) => {
|
|
94
|
+
if (mapping.source == null || mapping.originalLine == null || mapping.originalColumn == null) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const original = prevSmc.originalPositionFor({
|
|
98
|
+
line: mapping.originalLine,
|
|
99
|
+
column: mapping.originalColumn
|
|
100
|
+
});
|
|
101
|
+
if (original.source == null || original.line == null || original.column == null) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
smg.addMapping({
|
|
105
|
+
generated: {
|
|
106
|
+
line: mapping.generatedLine,
|
|
107
|
+
column: mapping.generatedColumn
|
|
108
|
+
},
|
|
109
|
+
original: {
|
|
110
|
+
line: original.line,
|
|
111
|
+
column: original.column
|
|
112
|
+
},
|
|
113
|
+
source: original.source,
|
|
114
|
+
name: original.name || mapping.name
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
if (prevMapObj.sourcesContent) {
|
|
118
|
+
prevMapObj.sources.forEach((src, i) => {
|
|
119
|
+
smg.setSourceContent(src, prevMapObj.sourcesContent[i]);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return smg.toString();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
|
|
35
126
|
var processedModules = /* @__PURE__ */ new Set();
|
|
36
127
|
var enableSourcemap = false;
|
|
37
128
|
if (!isMainThread) {
|
|
@@ -66,11 +157,7 @@ ${error.stack}`);
|
|
|
66
157
|
}
|
|
67
158
|
await writeCompileRes(mainCompileRes, null);
|
|
68
159
|
processedModules.clear();
|
|
69
|
-
parentPort.postMessage({
|
|
70
|
-
success: true,
|
|
71
|
-
compatibilityWarnings: takeCompatibilityWarnings(),
|
|
72
|
-
dependencyGraph: getDependencyGraph().toJSON()
|
|
73
|
-
});
|
|
160
|
+
parentPort.postMessage({ success: true });
|
|
74
161
|
} catch (error) {
|
|
75
162
|
processedModules.clear();
|
|
76
163
|
parentPort.postMessage({
|
|
@@ -123,12 +210,18 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
123
210
|
}
|
|
124
211
|
return compileRes;
|
|
125
212
|
}
|
|
126
|
-
async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra,
|
|
213
|
+
async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
|
|
127
214
|
const currentPath = module.path;
|
|
128
|
-
if (
|
|
215
|
+
if (depthChain.includes(currentPath)) {
|
|
216
|
+
console.warn("[logic]", `\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
129
217
|
return;
|
|
130
218
|
}
|
|
131
|
-
if (
|
|
219
|
+
if (depthChain.length > 20) {
|
|
220
|
+
console.warn("[logic]", `\u68C0\u6D4B\u5230\u6DF1\u5EA6\u4F9D\u8D56: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
depthChain = [...depthChain, currentPath];
|
|
224
|
+
if (!module.path) {
|
|
132
225
|
return;
|
|
133
226
|
}
|
|
134
227
|
if (hasCompileInfo(module.path, compileRes, mainCompileRes)) {
|
|
@@ -145,7 +238,6 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
145
238
|
console.warn("[logic]", `\u627E\u4E0D\u5230\u6A21\u5757\u6587\u4EF6: ${src}`);
|
|
146
239
|
return;
|
|
147
240
|
}
|
|
148
|
-
getDependencyGraph().addFile(currentPath, modulePath, "logic");
|
|
149
241
|
const diagnosticSource = modulePath.startsWith(getWorkPath()) ? modulePath.slice(getWorkPath().length) : src;
|
|
150
242
|
const sourceCode = getContentByPath(modulePath);
|
|
151
243
|
if (!sourceCode) {
|
|
@@ -166,19 +258,13 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
166
258
|
const extraInfo = {
|
|
167
259
|
path: module.path
|
|
168
260
|
};
|
|
169
|
-
activePaths.add(currentPath);
|
|
170
261
|
if (module.component) {
|
|
171
262
|
extraInfo.component = true;
|
|
172
263
|
}
|
|
173
264
|
if (module.usingComponents) {
|
|
174
265
|
const componentsObj = {};
|
|
175
266
|
const allSubPackages = getAppConfigInfo().subPackages;
|
|
176
|
-
const graphDependencies = getDependencyGraph().getDirectDependencies(module.path, "component");
|
|
177
|
-
const componentDependencies = graphDependencies.length > 0 ? new Set(graphDependencies) : null;
|
|
178
267
|
for (const [name, path] of Object.entries(module.usingComponents)) {
|
|
179
|
-
if (componentDependencies && !componentDependencies.has(path)) {
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
268
|
let toMainSubPackage = true;
|
|
183
269
|
if (packageName) {
|
|
184
270
|
const normalizedPath = path.startsWith("/") ? path.substring(1) : path;
|
|
@@ -195,7 +281,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
195
281
|
if (!componentModule) {
|
|
196
282
|
continue;
|
|
197
283
|
}
|
|
198
|
-
await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true,
|
|
284
|
+
await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, putMain || toMainSubPackage);
|
|
199
285
|
componentsObj[name] = path;
|
|
200
286
|
}
|
|
201
287
|
extraInfo.usingComponents = componentsObj;
|
|
@@ -227,11 +313,6 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
227
313
|
);
|
|
228
314
|
}
|
|
229
315
|
if ((node.type === "StringLiteral" || node.type === "Literal") && isLocalAssetString(node.value)) {
|
|
230
|
-
getDependencyGraph().addFile(
|
|
231
|
-
currentPath,
|
|
232
|
-
resolveAssetSourcePath(getWorkPath(), modulePath, node.value),
|
|
233
|
-
"logic"
|
|
234
|
-
);
|
|
235
316
|
pathReplacements.push({
|
|
236
317
|
start: node.start,
|
|
237
318
|
end: node.end,
|
|
@@ -247,7 +328,6 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
247
328
|
if (requirePath) {
|
|
248
329
|
const { id, shouldProcess } = resolveDependencyId(requirePath, modulePath, false);
|
|
249
330
|
if (shouldProcess) {
|
|
250
|
-
getDependencyGraph().addDependency(currentPath, id, "logic");
|
|
251
331
|
pathReplacements.push({
|
|
252
332
|
start: arg.start,
|
|
253
333
|
end: arg.end,
|
|
@@ -265,7 +345,6 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
265
345
|
if (importPath) {
|
|
266
346
|
const { id, shouldProcess } = resolveDependencyId(importPath, modulePath, true);
|
|
267
347
|
if (shouldProcess) {
|
|
268
|
-
getDependencyGraph().addDependency(currentPath, id, "logic");
|
|
269
348
|
pathReplacements.push({
|
|
270
349
|
start: node.source.start,
|
|
271
350
|
end: node.source.end,
|
|
@@ -283,7 +362,6 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
283
362
|
if (importPath) {
|
|
284
363
|
const { id, shouldProcess } = resolveDependencyId(importPath, modulePath, false);
|
|
285
364
|
if (shouldProcess) {
|
|
286
|
-
getDependencyGraph().addDependency(currentPath, id, "logic");
|
|
287
365
|
pathReplacements.push({
|
|
288
366
|
start: importPathNode.start,
|
|
289
367
|
end: importPathNode.end,
|
|
@@ -300,7 +378,6 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
300
378
|
if (exportPath) {
|
|
301
379
|
const { id, shouldProcess } = resolveDependencyId(exportPath, modulePath, true);
|
|
302
380
|
if (shouldProcess) {
|
|
303
|
-
getDependencyGraph().addDependency(currentPath, id, "logic");
|
|
304
381
|
pathReplacements.push({
|
|
305
382
|
start: node.source.start,
|
|
306
383
|
end: node.source.end,
|
|
@@ -315,7 +392,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
315
392
|
}
|
|
316
393
|
});
|
|
317
394
|
for (const depId of dependenciesToProcess) {
|
|
318
|
-
await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false,
|
|
395
|
+
await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false, depthChain, putMain);
|
|
319
396
|
}
|
|
320
397
|
for (const replacement of pathReplacements.reverse()) {
|
|
321
398
|
s.overwrite(replacement.start, replacement.end, `'${replacement.newValue}'`);
|
|
@@ -356,7 +433,6 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
356
433
|
compileInfo.code = modifiedCode;
|
|
357
434
|
}
|
|
358
435
|
processedModules.add(packageName + currentPath);
|
|
359
|
-
activePaths.delete(currentPath);
|
|
360
436
|
}
|
|
361
437
|
function isLocalAssetString(value) {
|
|
362
438
|
return typeof value === "string" && !value.startsWith("http") && !value.startsWith("//") && (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) && /\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(value);
|