binhend 1.4.1 → 1.4.3
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/package.json +1 -1
- package/src/code.js +10 -5
package/package.json
CHANGED
package/src/code.js
CHANGED
|
@@ -17,7 +17,7 @@ function getCodeOfDependencies(component, rootPath, metadata) {
|
|
|
17
17
|
var htmlTagDeclaration = getHtmlTagDeclaration(dependency);
|
|
18
18
|
|
|
19
19
|
if (dependencyDelaration) {
|
|
20
|
-
componentCode = componentCode
|
|
20
|
+
componentCode = injectFunctionCodeContent(componentCode, dependencyDelaration);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
var blockCodes = [];
|
|
@@ -42,6 +42,10 @@ function getCodeOfDependencies(component, rootPath, metadata) {
|
|
|
42
42
|
return codes.join('\r\n');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
function injectFunctionCodeContent(functionCodeString, injectionCode) {
|
|
46
|
+
return functionCodeString.replace(/(\(.*?\)\s*{|\(.*?\)\s*=>\s*{)/, `$1\r\n${injectionCode}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
function getDependencyDelaration(component, rootPath) {
|
|
46
50
|
var dependencies = getMetadataOfDependencies(component, rootPath);
|
|
47
51
|
var codes = [];
|
|
@@ -139,22 +143,23 @@ function getRelativeFilePath(filePath, rootPath) {
|
|
|
139
143
|
getRelativeFilePath.cache = {};
|
|
140
144
|
|
|
141
145
|
function bundle(component, rootPath) {
|
|
142
|
-
var codeOfDependencies = getCodeOfDependencies(component, rootPath);
|
|
143
146
|
var dependencyDelaration = getDependencyDelaration(component, rootPath);
|
|
144
147
|
var optionCode = generateOptionCode(component, '', rootPath);
|
|
145
148
|
var componentCode = component.toString();
|
|
146
149
|
|
|
147
150
|
if (dependencyDelaration) {
|
|
148
|
-
componentCode = componentCode
|
|
151
|
+
componentCode = injectFunctionCodeContent(componentCode, dependencyDelaration);
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
var codes = [];
|
|
152
155
|
|
|
153
|
-
if (codeOfDependencies) codes.push(codeOfDependencies);
|
|
154
156
|
if (componentCode) {
|
|
155
157
|
codes.push(`Binh.${component.type}(${component.type})${optionCode};`);
|
|
156
|
-
codes.push(`${componentCode}`);
|
|
158
|
+
codes.push(`${componentCode}\r\n`);
|
|
157
159
|
}
|
|
160
|
+
|
|
161
|
+
var codeOfDependencies = getCodeOfDependencies(component, rootPath);
|
|
162
|
+
if (codeOfDependencies) codes.push(codeOfDependencies);
|
|
158
163
|
|
|
159
164
|
return codes.join('\r\n');
|
|
160
165
|
}
|