@dimina/compiler 1.0.1 → 1.0.2
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 +3 -1
- package/dist/bin/index.cjs +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/core/logic-compiler.cjs +5 -5
- package/dist/core/logic-compiler.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/bin/index.cjs
CHANGED
package/dist/bin/index.js
CHANGED
|
@@ -79,7 +79,7 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
79
79
|
});
|
|
80
80
|
return compileRes;
|
|
81
81
|
}
|
|
82
|
-
function buildJSByPath(
|
|
82
|
+
function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
|
|
83
83
|
const currentPath = module2.path;
|
|
84
84
|
if (depthChain.includes(currentPath)) {
|
|
85
85
|
console.warn(`检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
@@ -114,8 +114,8 @@ function buildJSByPath(root, module2, compileRes, mainCompileRes, addExtra, dept
|
|
|
114
114
|
const allSubPackages = env.getAppConfigInfo().subPackages;
|
|
115
115
|
for (const [name, path2] of Object.entries(module2.usingComponents)) {
|
|
116
116
|
let toMainSubPackage = true;
|
|
117
|
-
if (
|
|
118
|
-
const rootPackageName =
|
|
117
|
+
if (packageName) {
|
|
118
|
+
const rootPackageName = packageName.startsWith("sub_") ? packageName.slice(4) : packageName;
|
|
119
119
|
const normalizedPath = path2.startsWith("/") ? path2.substring(1) : path2;
|
|
120
120
|
for (const subPackage of allSubPackages) {
|
|
121
121
|
if (normalizedPath.startsWith(`${subPackage.root}/`)) {
|
|
@@ -135,7 +135,7 @@ function buildJSByPath(root, module2, compileRes, mainCompileRes, addExtra, dept
|
|
|
135
135
|
if (!componentModule) {
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
|
-
buildJSByPath(
|
|
138
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, toMainSubPackage);
|
|
139
139
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path2));
|
|
140
140
|
components.value.properties.push(props);
|
|
141
141
|
}
|
|
@@ -158,7 +158,7 @@ function buildJSByPath(root, module2, compileRes, mainCompileRes, addExtra, dept
|
|
|
158
158
|
const id = requireFullPath.split(`${env.getWorkPath()}/`)[1].split(".js")[0];
|
|
159
159
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
160
160
|
if (!processedModules.has(id)) {
|
|
161
|
-
buildJSByPath(
|
|
161
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -78,7 +78,7 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
78
78
|
});
|
|
79
79
|
return compileRes;
|
|
80
80
|
}
|
|
81
|
-
function buildJSByPath(
|
|
81
|
+
function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, depthChain = [], putMain = false) {
|
|
82
82
|
const currentPath = module.path;
|
|
83
83
|
if (depthChain.includes(currentPath)) {
|
|
84
84
|
console.warn(`检测到循环依赖: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
@@ -113,8 +113,8 @@ function buildJSByPath(root, module, compileRes, mainCompileRes, addExtra, depth
|
|
|
113
113
|
const allSubPackages = getAppConfigInfo().subPackages;
|
|
114
114
|
for (const [name, path] of Object.entries(module.usingComponents)) {
|
|
115
115
|
let toMainSubPackage = true;
|
|
116
|
-
if (
|
|
117
|
-
const rootPackageName =
|
|
116
|
+
if (packageName) {
|
|
117
|
+
const rootPackageName = packageName.startsWith("sub_") ? packageName.slice(4) : packageName;
|
|
118
118
|
const normalizedPath = path.startsWith("/") ? path.substring(1) : path;
|
|
119
119
|
for (const subPackage of allSubPackages) {
|
|
120
120
|
if (normalizedPath.startsWith(`${subPackage.root}/`)) {
|
|
@@ -134,7 +134,7 @@ function buildJSByPath(root, module, compileRes, mainCompileRes, addExtra, depth
|
|
|
134
134
|
if (!componentModule) {
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
buildJSByPath(
|
|
137
|
+
buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, depthChain, toMainSubPackage);
|
|
138
138
|
const props = types.objectProperty(types.identifier(`'${name}'`), types.stringLiteral(path));
|
|
139
139
|
components.value.properties.push(props);
|
|
140
140
|
}
|
|
@@ -157,7 +157,7 @@ function buildJSByPath(root, module, compileRes, mainCompileRes, addExtra, depth
|
|
|
157
157
|
const id = requireFullPath.split(`${getWorkPath()}/`)[1].split(".js")[0];
|
|
158
158
|
ap.node.arguments[0] = types.stringLiteral(id);
|
|
159
159
|
if (!processedModules.has(id)) {
|
|
160
|
-
buildJSByPath(
|
|
160
|
+
buildJSByPath(packageName, { path: id }, compileRes, mainCompileRes, false, depthChain);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
}
|