@dimina/compiler 1.0.11 → 1.0.12-beta.1
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 +9 -20
- package/dist/core/logic-compiler.js +9 -20
- package/dist/core/style-compiler.cjs +4 -8
- package/dist/core/style-compiler.js +4 -8
- package/dist/core/view-compiler.cjs +6 -10
- package/dist/core/view-compiler.js +6 -10
- package/package.json +6 -3
package/dist/bin/index.cjs
CHANGED
package/dist/bin/index.js
CHANGED
|
@@ -95,22 +95,17 @@ 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
|
-
|
|
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(" -> ")}`);
|
|
98
|
+
if (!module2.path) {
|
|
105
99
|
return;
|
|
106
100
|
}
|
|
107
|
-
|
|
108
|
-
if (
|
|
101
|
+
const moduleKey = packageName + module2.path;
|
|
102
|
+
if (processedModules.has(moduleKey)) {
|
|
109
103
|
return;
|
|
110
104
|
}
|
|
111
105
|
if (env.hasCompileInfo(module2.path, compileRes, mainCompileRes)) {
|
|
112
106
|
return;
|
|
113
107
|
}
|
|
108
|
+
processedModules.add(moduleKey);
|
|
114
109
|
const compileInfo = {
|
|
115
110
|
path: module2.path,
|
|
116
111
|
code: ""
|
|
@@ -172,7 +167,7 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
172
167
|
if (!componentModule) {
|
|
173
168
|
continue;
|
|
174
169
|
}
|
|
175
|
-
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true,
|
|
170
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, toMainSubPackage);
|
|
176
171
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path2));
|
|
177
172
|
components.value.properties.push(props);
|
|
178
173
|
}
|
|
@@ -198,9 +193,7 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
198
193
|
id = "/" + id;
|
|
199
194
|
}
|
|
200
195
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
201
|
-
|
|
202
|
-
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
203
|
-
}
|
|
196
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false);
|
|
204
197
|
}
|
|
205
198
|
}
|
|
206
199
|
},
|
|
@@ -230,9 +223,7 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
230
223
|
}
|
|
231
224
|
if (shouldProcess) {
|
|
232
225
|
ap.node.source = types.stringLiteral(id);
|
|
233
|
-
|
|
234
|
-
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
235
|
-
}
|
|
226
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false);
|
|
236
227
|
}
|
|
237
228
|
}
|
|
238
229
|
}
|
|
@@ -245,14 +236,12 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
|
|
|
245
236
|
]
|
|
246
237
|
});
|
|
247
238
|
compileInfo.code = code;
|
|
248
|
-
processedModules.add(packageName + currentPath);
|
|
249
239
|
}
|
|
250
240
|
function getExtraInfoStatement(type, addedArgs) {
|
|
251
|
-
const propertyAssignment = types.objectProperty(types.identifier("__extraInfo"), addedArgs);
|
|
252
241
|
const assignmentExpression = types.assignmentExpression(
|
|
253
242
|
"=",
|
|
254
|
-
types.memberExpression(types.identifier("globalThis"),
|
|
255
|
-
|
|
243
|
+
types.memberExpression(types.identifier("globalThis"), types.identifier("__extraInfo")),
|
|
244
|
+
addedArgs
|
|
256
245
|
);
|
|
257
246
|
return types.expressionStatement(assignmentExpression);
|
|
258
247
|
}
|
|
@@ -93,22 +93,17 @@ 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
|
-
|
|
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(" -> ")}`);
|
|
96
|
+
if (!module.path) {
|
|
103
97
|
return;
|
|
104
98
|
}
|
|
105
|
-
|
|
106
|
-
if (
|
|
99
|
+
const moduleKey = packageName + module.path;
|
|
100
|
+
if (processedModules.has(moduleKey)) {
|
|
107
101
|
return;
|
|
108
102
|
}
|
|
109
103
|
if (hasCompileInfo(module.path, compileRes, mainCompileRes)) {
|
|
110
104
|
return;
|
|
111
105
|
}
|
|
106
|
+
processedModules.add(moduleKey);
|
|
112
107
|
const compileInfo = {
|
|
113
108
|
path: module.path,
|
|
114
109
|
code: ""
|
|
@@ -170,7 +165,7 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
170
165
|
if (!componentModule) {
|
|
171
166
|
continue;
|
|
172
167
|
}
|
|
173
|
-
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true,
|
|
168
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, toMainSubPackage);
|
|
174
169
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path));
|
|
175
170
|
components.value.properties.push(props);
|
|
176
171
|
}
|
|
@@ -196,9 +191,7 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
196
191
|
id = "/" + id;
|
|
197
192
|
}
|
|
198
193
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
199
|
-
|
|
200
|
-
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
201
|
-
}
|
|
194
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false);
|
|
202
195
|
}
|
|
203
196
|
}
|
|
204
197
|
},
|
|
@@ -228,9 +221,7 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
228
221
|
}
|
|
229
222
|
if (shouldProcess) {
|
|
230
223
|
ap.node.source = types.stringLiteral(id);
|
|
231
|
-
|
|
232
|
-
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
233
|
-
}
|
|
224
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false);
|
|
234
225
|
}
|
|
235
226
|
}
|
|
236
227
|
}
|
|
@@ -243,14 +234,12 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
|
|
|
243
234
|
]
|
|
244
235
|
});
|
|
245
236
|
compileInfo.code = code;
|
|
246
|
-
processedModules.add(packageName + currentPath);
|
|
247
237
|
}
|
|
248
238
|
function getExtraInfoStatement(type, addedArgs) {
|
|
249
|
-
const propertyAssignment = types.objectProperty(types.identifier("__extraInfo"), addedArgs);
|
|
250
239
|
const assignmentExpression = types.assignmentExpression(
|
|
251
240
|
"=",
|
|
252
|
-
types.memberExpression(types.identifier("globalThis"),
|
|
253
|
-
|
|
241
|
+
types.memberExpression(types.identifier("globalThis"), types.identifier("__extraInfo")),
|
|
242
|
+
addedArgs
|
|
254
243
|
);
|
|
255
244
|
return types.expressionStatement(assignmentExpression);
|
|
256
245
|
}
|
|
@@ -30,6 +30,7 @@ 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();
|
|
33
34
|
if (!node_worker_threads.isMainThread) {
|
|
34
35
|
node_worker_threads.parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
35
36
|
try {
|
|
@@ -83,15 +84,10 @@ async function compileSS(pages, root, progress) {
|
|
|
83
84
|
}
|
|
84
85
|
async function buildCompileCss(module2, depthChain = []) {
|
|
85
86
|
const currentPath = module2.path;
|
|
86
|
-
if (
|
|
87
|
-
console.warn("[style]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
87
|
+
if (processedPaths.has(currentPath)) {
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
console.warn("[style]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
depthChain = [...depthChain, currentPath];
|
|
90
|
+
processedPaths.add(currentPath);
|
|
95
91
|
let result = await enhanceCSS(module2) || "";
|
|
96
92
|
if (module2.usingComponents) {
|
|
97
93
|
for (const componentInfo of Object.values(module2.usingComponents)) {
|
|
@@ -99,7 +95,7 @@ async function buildCompileCss(module2, depthChain = []) {
|
|
|
99
95
|
if (!componentModule) {
|
|
100
96
|
continue;
|
|
101
97
|
}
|
|
102
|
-
result += await buildCompileCss(componentModule
|
|
98
|
+
result += await buildCompileCss(componentModule);
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
return result;
|
|
@@ -11,6 +11,7 @@ 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();
|
|
14
15
|
if (!isMainThread) {
|
|
15
16
|
parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
16
17
|
try {
|
|
@@ -64,15 +65,10 @@ async function compileSS(pages, root, progress) {
|
|
|
64
65
|
}
|
|
65
66
|
async function buildCompileCss(module, depthChain = []) {
|
|
66
67
|
const currentPath = module.path;
|
|
67
|
-
if (
|
|
68
|
-
console.warn("[style]", `检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
68
|
+
if (processedPaths.has(currentPath)) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
console.warn("[style]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
depthChain = [...depthChain, currentPath];
|
|
71
|
+
processedPaths.add(currentPath);
|
|
76
72
|
let result = await enhanceCSS(module) || "";
|
|
77
73
|
if (module.usingComponents) {
|
|
78
74
|
for (const componentInfo of Object.values(module.usingComponents)) {
|
|
@@ -80,7 +76,7 @@ async function buildCompileCss(module, depthChain = []) {
|
|
|
80
76
|
if (!componentModule) {
|
|
81
77
|
continue;
|
|
82
78
|
}
|
|
83
|
-
result += await buildCompileCss(componentModule
|
|
79
|
+
result += await buildCompileCss(componentModule);
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
82
|
return result;
|
|
@@ -140,6 +140,7 @@ 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();
|
|
143
144
|
if (!node_worker_threads.isMainThread) {
|
|
144
145
|
node_worker_threads.parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
145
146
|
try {
|
|
@@ -238,15 +239,10 @@ function isRegisteredWxsModule(modulePath) {
|
|
|
238
239
|
}
|
|
239
240
|
function buildCompileView(module2, isComponent = false, scriptRes, depthChain = []) {
|
|
240
241
|
const currentPath = module2.path;
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (depthChain.length > 20) {
|
|
246
|
-
console.warn("[view]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
247
|
-
return;
|
|
242
|
+
if (processedViewPaths.has(currentPath)) {
|
|
243
|
+
return null;
|
|
248
244
|
}
|
|
249
|
-
|
|
245
|
+
processedViewPaths.add(currentPath);
|
|
250
246
|
const allScriptModules = [];
|
|
251
247
|
const currentInstruction = compileModule(module2, isComponent, scriptRes);
|
|
252
248
|
if (currentInstruction && currentInstruction.scriptModule) {
|
|
@@ -259,10 +255,10 @@ function buildCompileView(module2, isComponent = false, scriptRes, depthChain =
|
|
|
259
255
|
continue;
|
|
260
256
|
}
|
|
261
257
|
if (componentModule.path === module2.path) {
|
|
262
|
-
console.warn("[view]",
|
|
258
|
+
console.warn("[view]", `检测到自依赖,跳过处理: ${module2.path}`);
|
|
263
259
|
continue;
|
|
264
260
|
}
|
|
265
|
-
const componentInstruction = buildCompileView(componentModule, true, scriptRes
|
|
261
|
+
const componentInstruction = buildCompileView(componentModule, true, scriptRes);
|
|
266
262
|
if (componentInstruction && componentInstruction.scriptModule) {
|
|
267
263
|
for (const sm of componentInstruction.scriptModule) {
|
|
268
264
|
if (!allScriptModules.find((existing) => existing.path === sm.path)) {
|
|
@@ -120,6 +120,7 @@ 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();
|
|
123
124
|
if (!isMainThread) {
|
|
124
125
|
parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
125
126
|
try {
|
|
@@ -218,15 +219,10 @@ function isRegisteredWxsModule(modulePath) {
|
|
|
218
219
|
}
|
|
219
220
|
function buildCompileView(module, isComponent = false, scriptRes, depthChain = []) {
|
|
220
221
|
const currentPath = module.path;
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
if (depthChain.length > 20) {
|
|
226
|
-
console.warn("[view]", `检测到深度依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
227
|
-
return;
|
|
222
|
+
if (processedViewPaths.has(currentPath)) {
|
|
223
|
+
return null;
|
|
228
224
|
}
|
|
229
|
-
|
|
225
|
+
processedViewPaths.add(currentPath);
|
|
230
226
|
const allScriptModules = [];
|
|
231
227
|
const currentInstruction = compileModule(module, isComponent, scriptRes);
|
|
232
228
|
if (currentInstruction && currentInstruction.scriptModule) {
|
|
@@ -239,10 +235,10 @@ function buildCompileView(module, isComponent = false, scriptRes, depthChain = [
|
|
|
239
235
|
continue;
|
|
240
236
|
}
|
|
241
237
|
if (componentModule.path === module.path) {
|
|
242
|
-
console.warn("[view]",
|
|
238
|
+
console.warn("[view]", `检测到自依赖,跳过处理: ${module.path}`);
|
|
243
239
|
continue;
|
|
244
240
|
}
|
|
245
|
-
const componentInstruction = buildCompileView(componentModule, true, scriptRes
|
|
241
|
+
const componentInstruction = buildCompileView(componentModule, true, scriptRes);
|
|
246
242
|
if (componentInstruction && componentInstruction.scriptModule) {
|
|
247
243
|
for (const sm of componentInstruction.scriptModule) {
|
|
248
244
|
if (!allScriptModules.find((existing) => existing.path === sm.path)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimina/compiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12-beta.1",
|
|
4
4
|
"description": "星河编译工具",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
"build": "vite build",
|
|
34
34
|
"test": "vitest run",
|
|
35
35
|
"test:dev": "vitest",
|
|
36
|
-
"coverage": "vitest run --coverage"
|
|
36
|
+
"coverage": "vitest run --coverage",
|
|
37
|
+
"release:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
|
|
38
|
+
"release": "npm version patch && npm publish"
|
|
37
39
|
},
|
|
38
40
|
"author": "doslin",
|
|
39
41
|
"license": "Apache-2.0",
|
|
@@ -65,6 +67,7 @@
|
|
|
65
67
|
"typescript": "^5.9.3"
|
|
66
68
|
},
|
|
67
69
|
"publishConfig": {
|
|
68
|
-
"registry": "https://registry.npmjs.org/"
|
|
70
|
+
"registry": "https://registry.npmjs.org/",
|
|
71
|
+
"access": "public"
|
|
69
72
|
}
|
|
70
73
|
}
|