binhend 2.1.35 → 2.1.36
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/index.js +3 -2
- package/package.json +1 -1
- package/src/web/component.build.js +2 -2
- package/src/web/index.js +15 -6
package/index.js
CHANGED
|
@@ -28,7 +28,7 @@ const typedefs = require('./src/utils/typedefs');
|
|
|
28
28
|
const Bromise = require('./src/utils/Bromise.js');
|
|
29
29
|
|
|
30
30
|
/** CLIENT - Frontend */
|
|
31
|
-
const {
|
|
31
|
+
const { WebBuild } = require('./src/web');
|
|
32
32
|
const { binh } = require('./src/web/component.method');
|
|
33
33
|
|
|
34
34
|
// Run scripts
|
|
@@ -50,6 +50,7 @@ module.exports = {
|
|
|
50
50
|
typedefs,
|
|
51
51
|
validation,
|
|
52
52
|
Bromise,
|
|
53
|
-
|
|
53
|
+
WebBuild,
|
|
54
|
+
WebBuilder: WebBuild,
|
|
54
55
|
binh
|
|
55
56
|
};
|
package/package.json
CHANGED
|
@@ -28,11 +28,11 @@ function processEachFile({ source: sourceRootPath, web: outputRootPath, module:
|
|
|
28
28
|
|
|
29
29
|
var filename = parseFileName(file.name);
|
|
30
30
|
|
|
31
|
-
if (!isAcceptedJS(filename)) {
|
|
31
|
+
if (!isAcceptedJS(filename)) { // if not JavaScript file (.js .cjs .mjs) => copy file from source path
|
|
32
32
|
return cloneFileIfNew(fileSourcePath, fileOutputPath);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
if (isExceptedJS(filename)) {
|
|
35
|
+
if (isExceptedJS(filename)) { // if JavaScript file is .c.js (exceptional file) => copy file from module path (stage path)
|
|
36
36
|
return cloneFileIfNew(fileStagePath, fileOutputPath);
|
|
37
37
|
}
|
|
38
38
|
|
package/src/web/index.js
CHANGED
|
@@ -8,32 +8,40 @@ const Component = require('./component');
|
|
|
8
8
|
const { server } = require('../server');
|
|
9
9
|
const express = require('express');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const DEFAULT_DIR_BUILD = 'build';
|
|
12
|
+
const DEFAULT_DIR_BUILD_WEB = 'web';
|
|
13
|
+
const DEFAULT_DIR_BUILD_MODULE = 'module';
|
|
14
|
+
const DEFAULT_DIR_BUILD_EXTERNAL = 'NPM';
|
|
15
|
+
|
|
16
|
+
function WebBuild(source, { output, external } = {}) {
|
|
12
17
|
|
|
13
18
|
if (isEmptyString(source)) throw new Error(`[BINHEND][WEB] Require source code location. Current: source: ${source}`);
|
|
14
19
|
|
|
15
20
|
source = path.resolve(source);
|
|
16
|
-
output = isString(output) ? output :
|
|
21
|
+
output = isString(output) ? output : DEFAULT_DIR_BUILD;
|
|
17
22
|
|
|
18
23
|
if (source === path.resolve(output)) throw new Error(`[BINHEND][WEB] Location of build output & source code should NOT be the same: ${source}`);
|
|
19
24
|
|
|
20
|
-
var module = path.resolve(output,
|
|
21
|
-
var web = path.resolve(output,
|
|
22
|
-
var external = mustString(external) ||
|
|
25
|
+
var module = path.resolve(output, DEFAULT_DIR_BUILD_MODULE);
|
|
26
|
+
var web = path.resolve(output, DEFAULT_DIR_BUILD_MODULE);
|
|
27
|
+
var external = mustString(external) || DEFAULT_DIR_BUILD_EXTERNAL;
|
|
23
28
|
|
|
24
29
|
this.bundle = () => {
|
|
25
30
|
Component.isLazy = false;
|
|
26
31
|
ComponentFormat.generate(source, module, () => ComponentBuild.bundle({ source, web, module }));
|
|
32
|
+
return this;
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
this.lazy = () => {
|
|
30
36
|
Component.isLazy = true;
|
|
31
37
|
ComponentFormat.generate(source, module, () => ComponentBuild.lazyload({ source, web, module, external }));
|
|
38
|
+
return this;
|
|
32
39
|
};
|
|
33
40
|
|
|
34
41
|
this.modulify = (outputModulePath) => {
|
|
35
42
|
outputModulePath = isString(outputModulePath) ? path.resolve(outputModulePath) : module;
|
|
36
43
|
ComponentFormat.generate(source, outputModulePath);
|
|
44
|
+
return this;
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
this.path = () => {
|
|
@@ -42,6 +50,7 @@ function WebBuilder(source, { output, external } = {}) {
|
|
|
42
50
|
|
|
43
51
|
this.minify = (flag = true) => {
|
|
44
52
|
Component.minification = flag;
|
|
53
|
+
return this;
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
setTimeout(() => {
|
|
@@ -55,5 +64,5 @@ function WebBuilder(source, { output, external } = {}) {
|
|
|
55
64
|
}
|
|
56
65
|
|
|
57
66
|
module.exports = {
|
|
58
|
-
|
|
67
|
+
WebBuild
|
|
59
68
|
};
|