@dimina/compiler 1.0.12-beta.0 → 1.0.12-beta.10
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 +29 -14
- package/dist/core/logic-compiler.js +29 -14
- package/dist/core/style-compiler.cjs +10 -4
- package/dist/core/style-compiler.js +10 -4
- package/dist/core/view-compiler.cjs +7263 -60
- package/dist/core/view-compiler.js +7263 -60
- package/dist/index.cjs +9 -6
- package/dist/index.js +9 -6
- package/package.json +13 -11
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.10";
|
|
9
9
|
const pack = {
|
|
10
10
|
version
|
|
11
11
|
};
|
package/dist/bin/index.js
CHANGED
|
@@ -11,6 +11,15 @@ const ts = require("typescript");
|
|
|
11
11
|
const transformModulesCommonjs = require("@babel/plugin-transform-modules-commonjs");
|
|
12
12
|
const env = require("../env-Cmen1qwy.cjs");
|
|
13
13
|
const traverse = _traverse.default ? _traverse.default : _traverse;
|
|
14
|
+
const BABEL_TRANSFORM_CONFIG = {
|
|
15
|
+
comments: false,
|
|
16
|
+
configFile: false,
|
|
17
|
+
babelrc: false,
|
|
18
|
+
plugins: [
|
|
19
|
+
// 将 ES6 import/export 转换为 CommonJS
|
|
20
|
+
transformModulesCommonjs
|
|
21
|
+
]
|
|
22
|
+
};
|
|
14
23
|
const processedModules = /* @__PURE__ */ new Set();
|
|
15
24
|
if (!node_worker_threads.isMainThread) {
|
|
16
25
|
node_worker_threads.parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
@@ -42,8 +51,10 @@ ${error.stack}`);
|
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
53
|
await writeCompileRes(mainCompileRes, null);
|
|
54
|
+
processedModules.clear();
|
|
45
55
|
node_worker_threads.parentPort.postMessage({ success: true });
|
|
46
56
|
} catch (error) {
|
|
57
|
+
processedModules.clear();
|
|
47
58
|
node_worker_threads.parentPort.postMessage({
|
|
48
59
|
success: false,
|
|
49
60
|
error: {
|
|
@@ -95,17 +106,22 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
95
106
|
return compileRes;
|
|
96
107
|
}
|
|
97
108
|
function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
|
|
98
|
-
|
|
109
|
+
const currentPath = module2.path;
|
|
110
|
+
if (depthChain.includes(currentPath)) {
|
|
111
|
+
console.warn("[logic]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (depthChain.length > 20) {
|
|
115
|
+
console.warn("[logic]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
99
116
|
return;
|
|
100
117
|
}
|
|
101
|
-
|
|
102
|
-
if (
|
|
118
|
+
depthChain = [...depthChain, currentPath];
|
|
119
|
+
if (!module2.path) {
|
|
103
120
|
return;
|
|
104
121
|
}
|
|
105
122
|
if (env.hasCompileInfo(module2.path, compileRes, mainCompileRes)) {
|
|
106
123
|
return;
|
|
107
124
|
}
|
|
108
|
-
processedModules.add(moduleKey);
|
|
109
125
|
const compileInfo = {
|
|
110
126
|
path: module2.path,
|
|
111
127
|
code: ""
|
|
@@ -167,7 +183,7 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
167
183
|
if (!componentModule) {
|
|
168
184
|
continue;
|
|
169
185
|
}
|
|
170
|
-
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, toMainSubPackage);
|
|
186
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, toMainSubPackage);
|
|
171
187
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path2));
|
|
172
188
|
components.value.properties.push(props);
|
|
173
189
|
}
|
|
@@ -193,7 +209,9 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
193
209
|
id = "/" + id;
|
|
194
210
|
}
|
|
195
211
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
196
|
-
|
|
212
|
+
if (!processedModules.has(packageName + id)) {
|
|
213
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
214
|
+
}
|
|
197
215
|
}
|
|
198
216
|
}
|
|
199
217
|
},
|
|
@@ -223,19 +241,16 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
223
241
|
}
|
|
224
242
|
if (shouldProcess) {
|
|
225
243
|
ap.node.source = types.stringLiteral(id);
|
|
226
|
-
|
|
244
|
+
if (!processedModules.has(packageName + id)) {
|
|
245
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
246
|
+
}
|
|
227
247
|
}
|
|
228
248
|
}
|
|
229
249
|
}
|
|
230
250
|
});
|
|
231
|
-
const { code } = babel.transformFromAstSync(ast, "",
|
|
232
|
-
comments: false,
|
|
233
|
-
plugins: [
|
|
234
|
-
// 将 ES6 import/export 转换为 CommonJS
|
|
235
|
-
transformModulesCommonjs
|
|
236
|
-
]
|
|
237
|
-
});
|
|
251
|
+
const { code } = babel.transformFromAstSync(ast, "", BABEL_TRANSFORM_CONFIG);
|
|
238
252
|
compileInfo.code = code;
|
|
253
|
+
processedModules.add(packageName + currentPath);
|
|
239
254
|
}
|
|
240
255
|
function getExtraInfoStatement(type, addedArgs) {
|
|
241
256
|
const propertyAssignment = types.objectProperty(types.identifier("__extraInfo"), addedArgs);
|
|
@@ -9,6 +9,15 @@ import ts from "typescript";
|
|
|
9
9
|
import transformModulesCommonjs from "@babel/plugin-transform-modules-commonjs";
|
|
10
10
|
import { r as resetStoreInfo, g as getTargetPath, i as hasCompileInfo, b as getContentByPath, j as getAppConfigInfo, a as getComponent, d as getWorkPath } from "../env-Csj3AHY4.js";
|
|
11
11
|
const traverse = _traverse.default ? _traverse.default : _traverse;
|
|
12
|
+
const BABEL_TRANSFORM_CONFIG = {
|
|
13
|
+
comments: false,
|
|
14
|
+
configFile: false,
|
|
15
|
+
babelrc: false,
|
|
16
|
+
plugins: [
|
|
17
|
+
// 将 ES6 import/export 转换为 CommonJS
|
|
18
|
+
transformModulesCommonjs
|
|
19
|
+
]
|
|
20
|
+
};
|
|
12
21
|
const processedModules = /* @__PURE__ */ new Set();
|
|
13
22
|
if (!isMainThread) {
|
|
14
23
|
parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
@@ -40,8 +49,10 @@ ${error.stack}`);
|
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
await writeCompileRes(mainCompileRes, null);
|
|
52
|
+
processedModules.clear();
|
|
43
53
|
parentPort.postMessage({ success: true });
|
|
44
54
|
} catch (error) {
|
|
55
|
+
processedModules.clear();
|
|
45
56
|
parentPort.postMessage({
|
|
46
57
|
success: false,
|
|
47
58
|
error: {
|
|
@@ -93,17 +104,22 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
93
104
|
return compileRes;
|
|
94
105
|
}
|
|
95
106
|
function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
|
|
96
|
-
|
|
107
|
+
const currentPath = module.path;
|
|
108
|
+
if (depthChain.includes(currentPath)) {
|
|
109
|
+
console.warn("[logic]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (depthChain.length > 20) {
|
|
113
|
+
console.warn("[logic]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
97
114
|
return;
|
|
98
115
|
}
|
|
99
|
-
|
|
100
|
-
if (
|
|
116
|
+
depthChain = [...depthChain, currentPath];
|
|
117
|
+
if (!module.path) {
|
|
101
118
|
return;
|
|
102
119
|
}
|
|
103
120
|
if (hasCompileInfo(module.path, compileRes, mainCompileRes)) {
|
|
104
121
|
return;
|
|
105
122
|
}
|
|
106
|
-
processedModules.add(moduleKey);
|
|
107
123
|
const compileInfo = {
|
|
108
124
|
path: module.path,
|
|
109
125
|
code: ""
|
|
@@ -165,7 +181,7 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
165
181
|
if (!componentModule) {
|
|
166
182
|
continue;
|
|
167
183
|
}
|
|
168
|
-
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, toMainSubPackage);
|
|
184
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, toMainSubPackage);
|
|
169
185
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path));
|
|
170
186
|
components.value.properties.push(props);
|
|
171
187
|
}
|
|
@@ -191,7 +207,9 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
191
207
|
id = "/" + id;
|
|
192
208
|
}
|
|
193
209
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
194
|
-
|
|
210
|
+
if (!processedModules.has(packageName + id)) {
|
|
211
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
212
|
+
}
|
|
195
213
|
}
|
|
196
214
|
}
|
|
197
215
|
},
|
|
@@ -221,19 +239,16 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
221
239
|
}
|
|
222
240
|
if (shouldProcess) {
|
|
223
241
|
ap.node.source = types.stringLiteral(id);
|
|
224
|
-
|
|
242
|
+
if (!processedModules.has(packageName + id)) {
|
|
243
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
244
|
+
}
|
|
225
245
|
}
|
|
226
246
|
}
|
|
227
247
|
}
|
|
228
248
|
});
|
|
229
|
-
const { code } = babel.transformFromAstSync(ast, "",
|
|
230
|
-
comments: false,
|
|
231
|
-
plugins: [
|
|
232
|
-
// 将 ES6 import/export 转换为 CommonJS
|
|
233
|
-
transformModulesCommonjs
|
|
234
|
-
]
|
|
235
|
-
});
|
|
249
|
+
const { code } = babel.transformFromAstSync(ast, "", BABEL_TRANSFORM_CONFIG);
|
|
236
250
|
compileInfo.code = code;
|
|
251
|
+
processedModules.add(packageName + currentPath);
|
|
237
252
|
}
|
|
238
253
|
function getExtraInfoStatement(type, addedArgs) {
|
|
239
254
|
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 {
|
|
@@ -49,8 +48,10 @@ if (!node_worker_threads.isMainThread) {
|
|
|
49
48
|
for (const [root, subPages] of Object.entries(pages.subPages)) {
|
|
50
49
|
await compileSS(subPages.info, root, progress);
|
|
51
50
|
}
|
|
51
|
+
compileRes.clear();
|
|
52
52
|
node_worker_threads.parentPort.postMessage({ success: true });
|
|
53
53
|
} catch (error) {
|
|
54
|
+
compileRes.clear();
|
|
54
55
|
node_worker_threads.parentPort.postMessage({
|
|
55
56
|
success: false,
|
|
56
57
|
error: {
|
|
@@ -84,10 +85,15 @@ async function compileSS(pages, root, progress) {
|
|
|
84
85
|
}
|
|
85
86
|
async function buildCompileCss(module2, depthChain = []) {
|
|
86
87
|
const currentPath = module2.path;
|
|
87
|
-
if (
|
|
88
|
+
if (depthChain.includes(currentPath)) {
|
|
89
|
+
console.warn("[style]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
|
-
|
|
92
|
+
if (depthChain.length > 20) {
|
|
93
|
+
console.warn("[style]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
depthChain = [...depthChain, currentPath];
|
|
91
97
|
let result = await enhanceCSS(module2) || "";
|
|
92
98
|
if (module2.usingComponents) {
|
|
93
99
|
for (const componentInfo of Object.values(module2.usingComponents)) {
|
|
@@ -95,7 +101,7 @@ async function buildCompileCss(module2, depthChain = []) {
|
|
|
95
101
|
if (!componentModule) {
|
|
96
102
|
continue;
|
|
97
103
|
}
|
|
98
|
-
result += await buildCompileCss(componentModule);
|
|
104
|
+
result += await buildCompileCss(componentModule, depthChain);
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
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 {
|
|
@@ -30,8 +29,10 @@ if (!isMainThread) {
|
|
|
30
29
|
for (const [root, subPages] of Object.entries(pages.subPages)) {
|
|
31
30
|
await compileSS(subPages.info, root, progress);
|
|
32
31
|
}
|
|
32
|
+
compileRes.clear();
|
|
33
33
|
parentPort.postMessage({ success: true });
|
|
34
34
|
} catch (error) {
|
|
35
|
+
compileRes.clear();
|
|
35
36
|
parentPort.postMessage({
|
|
36
37
|
success: false,
|
|
37
38
|
error: {
|
|
@@ -65,10 +66,15 @@ async function compileSS(pages, root, progress) {
|
|
|
65
66
|
}
|
|
66
67
|
async function buildCompileCss(module, depthChain = []) {
|
|
67
68
|
const currentPath = module.path;
|
|
68
|
-
if (
|
|
69
|
+
if (depthChain.includes(currentPath)) {
|
|
70
|
+
console.warn("[style]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
if (depthChain.length > 20) {
|
|
74
|
+
console.warn("[style]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
depthChain = [...depthChain, currentPath];
|
|
72
78
|
let result = await enhanceCSS(module) || "";
|
|
73
79
|
if (module.usingComponents) {
|
|
74
80
|
for (const componentInfo of Object.values(module.usingComponents)) {
|
|
@@ -76,7 +82,7 @@ async function buildCompileCss(module, depthChain = []) {
|
|
|
76
82
|
if (!componentModule) {
|
|
77
83
|
continue;
|
|
78
84
|
}
|
|
79
|
-
result += await buildCompileCss(componentModule);
|
|
85
|
+
result += await buildCompileCss(componentModule, depthChain);
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
return result;
|