@dimina/compiler 1.0.12-beta.3 → 1.0.12-beta.5
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/bin/index.cjs +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/core/logic-compiler.cjs +17 -7
- package/dist/core/logic-compiler.js +17 -7
- package/dist/core/style-compiler.cjs +8 -4
- package/dist/core/style-compiler.js +8 -4
- package/dist/core/view-compiler.cjs +10 -6
- package/dist/core/view-compiler.js +10 -6
- package/package.json +1 -1
package/dist/bin/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const process = require("node:process");
|
|
|
5
5
|
const chokidar = require("chokidar");
|
|
6
6
|
const commander = require("commander");
|
|
7
7
|
const index = require("../index.cjs");
|
|
8
|
-
const version = "1.0.12-beta.
|
|
8
|
+
const version = "1.0.12-beta.4";
|
|
9
9
|
const pack = {
|
|
10
10
|
version
|
|
11
11
|
};
|
package/dist/bin/index.js
CHANGED
|
@@ -95,17 +95,22 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
95
95
|
return compileRes;
|
|
96
96
|
}
|
|
97
97
|
function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
|
|
98
|
-
|
|
98
|
+
const currentPath = module2.path;
|
|
99
|
+
if (depthChain.includes(currentPath)) {
|
|
100
|
+
console.warn("[logic]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (depthChain.length > 20) {
|
|
104
|
+
console.warn("[logic]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
|
-
|
|
102
|
-
if (
|
|
107
|
+
depthChain = [...depthChain, currentPath];
|
|
108
|
+
if (!module2.path) {
|
|
103
109
|
return;
|
|
104
110
|
}
|
|
105
111
|
if (env.hasCompileInfo(module2.path, compileRes, mainCompileRes)) {
|
|
106
112
|
return;
|
|
107
113
|
}
|
|
108
|
-
processedModules.add(moduleKey);
|
|
109
114
|
const compileInfo = {
|
|
110
115
|
path: module2.path,
|
|
111
116
|
code: ""
|
|
@@ -167,7 +172,7 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
167
172
|
if (!componentModule) {
|
|
168
173
|
continue;
|
|
169
174
|
}
|
|
170
|
-
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, toMainSubPackage);
|
|
175
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, toMainSubPackage);
|
|
171
176
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path2));
|
|
172
177
|
components.value.properties.push(props);
|
|
173
178
|
}
|
|
@@ -193,7 +198,9 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
193
198
|
id = "/" + id;
|
|
194
199
|
}
|
|
195
200
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
196
|
-
|
|
201
|
+
if (!processedModules.has(packageName + id)) {
|
|
202
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
203
|
+
}
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
206
|
},
|
|
@@ -223,7 +230,9 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
223
230
|
}
|
|
224
231
|
if (shouldProcess) {
|
|
225
232
|
ap.node.source = types.stringLiteral(id);
|
|
226
|
-
|
|
233
|
+
if (!processedModules.has(packageName + id)) {
|
|
234
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
235
|
+
}
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
}
|
|
@@ -236,6 +245,7 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
236
245
|
]
|
|
237
246
|
});
|
|
238
247
|
compileInfo.code = code;
|
|
248
|
+
processedModules.add(packageName + currentPath);
|
|
239
249
|
}
|
|
240
250
|
function getExtraInfoStatement(type, addedArgs) {
|
|
241
251
|
const propertyAssignment = types.objectProperty(types.identifier("__extraInfo"), addedArgs);
|
|
@@ -93,17 +93,22 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
93
93
|
return compileRes;
|
|
94
94
|
}
|
|
95
95
|
function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
|
|
96
|
-
|
|
96
|
+
const currentPath = module.path;
|
|
97
|
+
if (depthChain.includes(currentPath)) {
|
|
98
|
+
console.warn("[logic]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (depthChain.length > 20) {
|
|
102
|
+
console.warn("[logic]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
97
103
|
return;
|
|
98
104
|
}
|
|
99
|
-
|
|
100
|
-
if (
|
|
105
|
+
depthChain = [...depthChain, currentPath];
|
|
106
|
+
if (!module.path) {
|
|
101
107
|
return;
|
|
102
108
|
}
|
|
103
109
|
if (hasCompileInfo(module.path, compileRes, mainCompileRes)) {
|
|
104
110
|
return;
|
|
105
111
|
}
|
|
106
|
-
processedModules.add(moduleKey);
|
|
107
112
|
const compileInfo = {
|
|
108
113
|
path: module.path,
|
|
109
114
|
code: ""
|
|
@@ -165,7 +170,7 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
165
170
|
if (!componentModule) {
|
|
166
171
|
continue;
|
|
167
172
|
}
|
|
168
|
-
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, toMainSubPackage);
|
|
173
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, toMainSubPackage);
|
|
169
174
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path));
|
|
170
175
|
components.value.properties.push(props);
|
|
171
176
|
}
|
|
@@ -191,7 +196,9 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
191
196
|
id = "/" + id;
|
|
192
197
|
}
|
|
193
198
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
194
|
-
|
|
199
|
+
if (!processedModules.has(packageName + id)) {
|
|
200
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
201
|
+
}
|
|
195
202
|
}
|
|
196
203
|
}
|
|
197
204
|
},
|
|
@@ -221,7 +228,9 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
221
228
|
}
|
|
222
229
|
if (shouldProcess) {
|
|
223
230
|
ap.node.source = types.stringLiteral(id);
|
|
224
|
-
|
|
231
|
+
if (!processedModules.has(packageName + id)) {
|
|
232
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
233
|
+
}
|
|
225
234
|
}
|
|
226
235
|
}
|
|
227
236
|
}
|
|
@@ -234,6 +243,7 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
234
243
|
]
|
|
235
244
|
});
|
|
236
245
|
compileInfo.code = code;
|
|
246
|
+
processedModules.add(packageName + currentPath);
|
|
237
247
|
}
|
|
238
248
|
function getExtraInfoStatement(type, addedArgs) {
|
|
239
249
|
const propertyAssignment = types.objectProperty(types.identifier("__extraInfo"), addedArgs);
|
|
@@ -30,7 +30,6 @@ function _interopNamespaceDefault(e) {
|
|
|
30
30
|
const sass__namespace = /* @__PURE__ */ _interopNamespaceDefault(sass);
|
|
31
31
|
const fileType = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
32
32
|
const compileRes = /* @__PURE__ */ new Map();
|
|
33
|
-
const processedPaths = /* @__PURE__ */ new Set();
|
|
34
33
|
if (!node_worker_threads.isMainThread) {
|
|
35
34
|
node_worker_threads.parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
36
35
|
try {
|
|
@@ -84,10 +83,15 @@ async function compileSS(pages, root, progress) {
|
|
|
84
83
|
}
|
|
85
84
|
async function buildCompileCss(module2, depthChain = []) {
|
|
86
85
|
const currentPath = module2.path;
|
|
87
|
-
if (
|
|
86
|
+
if (depthChain.includes(currentPath)) {
|
|
87
|
+
console.warn("[style]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
if (depthChain.length > 20) {
|
|
91
|
+
console.warn("[style]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
depthChain = [...depthChain, currentPath];
|
|
91
95
|
let result = await enhanceCSS(module2) || "";
|
|
92
96
|
if (module2.usingComponents) {
|
|
93
97
|
for (const componentInfo of Object.values(module2.usingComponents)) {
|
|
@@ -95,7 +99,7 @@ async function buildCompileCss(module2, depthChain = []) {
|
|
|
95
99
|
if (!componentModule) {
|
|
96
100
|
continue;
|
|
97
101
|
}
|
|
98
|
-
result += await buildCompileCss(componentModule);
|
|
102
|
+
result += await buildCompileCss(componentModule, depthChain);
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
return result;
|
|
@@ -11,7 +11,6 @@ import * as sass from "sass";
|
|
|
11
11
|
import { r as resetStoreInfo, g as getTargetPath, a as getComponent, b as getContentByPath, h as tagWhiteList, e as collectAssets, f as getAppId, d as getWorkPath, t as transformRpx } from "../env-Csj3AHY4.js";
|
|
12
12
|
const fileType = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
13
13
|
const compileRes = /* @__PURE__ */ new Map();
|
|
14
|
-
const processedPaths = /* @__PURE__ */ new Set();
|
|
15
14
|
if (!isMainThread) {
|
|
16
15
|
parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
17
16
|
try {
|
|
@@ -65,10 +64,15 @@ async function compileSS(pages, root, progress) {
|
|
|
65
64
|
}
|
|
66
65
|
async function buildCompileCss(module, depthChain = []) {
|
|
67
66
|
const currentPath = module.path;
|
|
68
|
-
if (
|
|
67
|
+
if (depthChain.includes(currentPath)) {
|
|
68
|
+
console.warn("[style]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
if (depthChain.length > 20) {
|
|
72
|
+
console.warn("[style]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
depthChain = [...depthChain, currentPath];
|
|
72
76
|
let result = await enhanceCSS(module) || "";
|
|
73
77
|
if (module.usingComponents) {
|
|
74
78
|
for (const componentInfo of Object.values(module.usingComponents)) {
|
|
@@ -76,7 +80,7 @@ async function buildCompileCss(module, depthChain = []) {
|
|
|
76
80
|
if (!componentModule) {
|
|
77
81
|
continue;
|
|
78
82
|
}
|
|
79
|
-
result += await buildCompileCss(componentModule);
|
|
83
|
+
result += await buildCompileCss(componentModule, depthChain);
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
return result;
|
|
@@ -140,7 +140,6 @@ const fileType = [".wxml", ".ddml"];
|
|
|
140
140
|
const compileResCache = /* @__PURE__ */ new Map();
|
|
141
141
|
const wxsModuleRegistry = /* @__PURE__ */ new Set();
|
|
142
142
|
const wxsFilePathMap = /* @__PURE__ */ new Map();
|
|
143
|
-
const processedViewPaths = /* @__PURE__ */ new Set();
|
|
144
143
|
if (!node_worker_threads.isMainThread) {
|
|
145
144
|
node_worker_threads.parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
146
145
|
try {
|
|
@@ -239,10 +238,15 @@ function isRegisteredWxsModule(modulePath) {
|
|
|
239
238
|
}
|
|
240
239
|
function buildCompileView(module2, isComponent = false, scriptRes, depthChain = []) {
|
|
241
240
|
const currentPath = module2.path;
|
|
242
|
-
if (
|
|
243
|
-
|
|
241
|
+
if (depthChain.includes(currentPath)) {
|
|
242
|
+
console.warn("[view]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (depthChain.length > 20) {
|
|
246
|
+
console.warn("[view]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
247
|
+
return;
|
|
244
248
|
}
|
|
245
|
-
|
|
249
|
+
depthChain = [...depthChain, currentPath];
|
|
246
250
|
const allScriptModules = [];
|
|
247
251
|
const currentInstruction = compileModule(module2, isComponent, scriptRes);
|
|
248
252
|
if (currentInstruction && currentInstruction.scriptModule) {
|
|
@@ -255,10 +259,10 @@ function buildCompileView(module2, isComponent = false, scriptRes, depthChain =
|
|
|
255
259
|
continue;
|
|
256
260
|
}
|
|
257
261
|
if (componentModule.path === module2.path) {
|
|
258
|
-
console.warn("[view]",
|
|
262
|
+
console.warn("[view]", `检测到循环依赖,跳过处理: ${module2.path}`);
|
|
259
263
|
continue;
|
|
260
264
|
}
|
|
261
|
-
const componentInstruction = buildCompileView(componentModule, true, scriptRes);
|
|
265
|
+
const componentInstruction = buildCompileView(componentModule, true, scriptRes, depthChain);
|
|
262
266
|
if (componentInstruction && componentInstruction.scriptModule) {
|
|
263
267
|
for (const sm of componentInstruction.scriptModule) {
|
|
264
268
|
if (!allScriptModules.find((existing) => existing.path === sm.path)) {
|
|
@@ -120,7 +120,6 @@ const fileType = [".wxml", ".ddml"];
|
|
|
120
120
|
const compileResCache = /* @__PURE__ */ new Map();
|
|
121
121
|
const wxsModuleRegistry = /* @__PURE__ */ new Set();
|
|
122
122
|
const wxsFilePathMap = /* @__PURE__ */ new Map();
|
|
123
|
-
const processedViewPaths = /* @__PURE__ */ new Set();
|
|
124
123
|
if (!isMainThread) {
|
|
125
124
|
parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
126
125
|
try {
|
|
@@ -219,10 +218,15 @@ function isRegisteredWxsModule(modulePath) {
|
|
|
219
218
|
}
|
|
220
219
|
function buildCompileView(module, isComponent = false, scriptRes, depthChain = []) {
|
|
221
220
|
const currentPath = module.path;
|
|
222
|
-
if (
|
|
223
|
-
|
|
221
|
+
if (depthChain.includes(currentPath)) {
|
|
222
|
+
console.warn("[view]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (depthChain.length > 20) {
|
|
226
|
+
console.warn("[view]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
227
|
+
return;
|
|
224
228
|
}
|
|
225
|
-
|
|
229
|
+
depthChain = [...depthChain, currentPath];
|
|
226
230
|
const allScriptModules = [];
|
|
227
231
|
const currentInstruction = compileModule(module, isComponent, scriptRes);
|
|
228
232
|
if (currentInstruction && currentInstruction.scriptModule) {
|
|
@@ -235,10 +239,10 @@ function buildCompileView(module, isComponent = false, scriptRes, depthChain = [
|
|
|
235
239
|
continue;
|
|
236
240
|
}
|
|
237
241
|
if (componentModule.path === module.path) {
|
|
238
|
-
console.warn("[view]",
|
|
242
|
+
console.warn("[view]", `检测到循环依赖,跳过处理: ${module.path}`);
|
|
239
243
|
continue;
|
|
240
244
|
}
|
|
241
|
-
const componentInstruction = buildCompileView(componentModule, true, scriptRes);
|
|
245
|
+
const componentInstruction = buildCompileView(componentModule, true, scriptRes, depthChain);
|
|
242
246
|
if (componentInstruction && componentInstruction.scriptModule) {
|
|
243
247
|
for (const sm of componentInstruction.scriptModule) {
|
|
244
248
|
if (!allScriptModules.find((existing) => existing.path === sm.path)) {
|