@plotdb/srcbuild 0.0.60 → 0.0.62
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 +7 -18
- package/dist/ext/bundle.js +24 -13
- package/dist/ext/pug.js +14 -11
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -245,30 +245,14 @@ Additionally, you can also use a list of modules:
|
|
|
245
245
|
|
|
246
246
|
Use the second option object to specify additional parameters, including:
|
|
247
247
|
|
|
248
|
-
- `pack`: *experimental* default false. Enable auto packing or not.
|
|
248
|
+
- `pack`: *experimental* *deprecated* default false. Enable auto packing or not.
|
|
249
249
|
- if true, enable auto packing which trigger bundling automatically to a filename from md5 of all script urls.
|
|
250
250
|
- require `bundler` option in pugbuild constructor.
|
|
251
251
|
- doesn't work with external urls.
|
|
252
252
|
- there are still issues about rebuilding and build from view.
|
|
253
|
+
- replaced by `bundle` filter, which runs in compile time.
|
|
253
254
|
- `min`: default true. When true, use minimized packed file with pack option.
|
|
254
255
|
|
|
255
|
-
#### Auto Packing Issue (TODO)
|
|
256
|
-
|
|
257
|
-
Auto packing works fine with static built files. However, there are two issues:
|
|
258
|
-
|
|
259
|
-
- it's kinda tricky to trigger a pack file rebuild if the pack file is mssing - since there is no clue from the hashed file name to the urls used.
|
|
260
|
-
- may slow down dynamic generated views since each rendering checks if the bundled file should be rebuilt against its source files.
|
|
261
|
-
- doesn't work for external urls.
|
|
262
|
-
|
|
263
|
-
For the above issues, we can:
|
|
264
|
-
|
|
265
|
-
- add additional information ( such as source pug name base64 string ) in the hashed file name for reversed resolving all source files
|
|
266
|
-
- completely ignore auto packing with dynamic view rendering, instead we support ODB of bundle files
|
|
267
|
-
- extend bundler to support remote file fetching
|
|
268
|
-
|
|
269
|
-
These solutions will be left in TODOs.
|
|
270
|
-
|
|
271
|
-
|
|
272
256
|
|
|
273
257
|
### Filters
|
|
274
258
|
|
|
@@ -277,6 +261,11 @@ Following formats and filters are supported:
|
|
|
277
261
|
- `lsc`: transpile content from livescript to JavaScript.
|
|
278
262
|
- `stylus`: transpile content from `stylus` to `CSS`.
|
|
279
263
|
- `md`: transpile content from `markdown` to `HTML`.
|
|
264
|
+
- `bundle`: bundle files including js, css or block. usage sample:
|
|
265
|
+
|
|
266
|
+
:bundle(options = {type: "block", files: [ { bid }, ... ]})
|
|
267
|
+
|
|
268
|
+
|
|
280
269
|
|
|
281
270
|
|
|
282
271
|
### JS functions
|
package/dist/ext/bundle.js
CHANGED
|
@@ -419,9 +419,11 @@ build.prototype = import$(Object.create(base.prototype), {
|
|
|
419
419
|
function fn$(n){
|
|
420
420
|
if (typeof n === 'string') {
|
|
421
421
|
return path.join(this$.reldir, n);
|
|
422
|
-
} else {
|
|
423
|
-
return this$.getPath(n);
|
|
424
422
|
}
|
|
423
|
+
if (!n.type) {
|
|
424
|
+
n.type = type;
|
|
425
|
+
}
|
|
426
|
+
return this$.getPath(n);
|
|
425
427
|
}
|
|
426
428
|
},
|
|
427
429
|
loadCaches: function(){
|
|
@@ -539,18 +541,13 @@ build.prototype = import$(Object.create(base.prototype), {
|
|
|
539
541
|
return this.specmgr.touchCode(files);
|
|
540
542
|
},
|
|
541
543
|
desPath: function(arg$){
|
|
542
|
-
var name, type
|
|
544
|
+
var name, type;
|
|
543
545
|
name = arg$.name, type = arg$.type;
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
return {
|
|
550
|
-
desdir: desdir,
|
|
551
|
-
des: des,
|
|
552
|
-
desMin: desMin
|
|
553
|
-
};
|
|
546
|
+
return build.desPath({
|
|
547
|
+
desdir: this.desdir,
|
|
548
|
+
name: name,
|
|
549
|
+
type: type
|
|
550
|
+
});
|
|
554
551
|
},
|
|
555
552
|
buildBySpec: function(spec){
|
|
556
553
|
var this$ = this;
|
|
@@ -641,6 +638,20 @@ build.prototype = import$(Object.create(base.prototype), {
|
|
|
641
638
|
});
|
|
642
639
|
}
|
|
643
640
|
});
|
|
641
|
+
build.desPath = function(arg$){
|
|
642
|
+
var desdir, name, type, _desdir, ext, des, desMin;
|
|
643
|
+
desdir = arg$.desdir, name = arg$.name, type = arg$.type;
|
|
644
|
+
_desdir = path.join(desdir, 'assets', 'bundle');
|
|
645
|
+
ext = type === 'block' ? 'html' : type;
|
|
646
|
+
des = path.join(_desdir, name + "." + ext);
|
|
647
|
+
desMin = path.join(_desdir, name + ".min." + ext);
|
|
648
|
+
desdir = path.dirname(des);
|
|
649
|
+
return {
|
|
650
|
+
desdir: desdir,
|
|
651
|
+
des: des,
|
|
652
|
+
desMin: desMin
|
|
653
|
+
};
|
|
654
|
+
};
|
|
644
655
|
module.exports = build;
|
|
645
656
|
function import$(obj, src){
|
|
646
657
|
var own = {}.hasOwnProperty;
|
package/dist/ext/pug.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by LiveScript 1.6.0
|
|
2
|
-
var fs, path, fsExtra, pug, livescript, uglifyJs, uglifycss, stylus, jsYaml, marked, crypto, colors, base, aux, cwd, pugbuild;
|
|
2
|
+
var fs, path, fsExtra, pug, livescript, uglifyJs, uglifycss, stylus, jsYaml, marked, crypto, colors, base, aux, bundle, cwd, pugbuild;
|
|
3
3
|
fs = require('fs');
|
|
4
4
|
path = require('path');
|
|
5
5
|
fsExtra = require('fs-extra');
|
|
@@ -14,6 +14,7 @@ crypto = require('crypto');
|
|
|
14
14
|
colors = require('@plotdb/colors');
|
|
15
15
|
base = require('./base');
|
|
16
16
|
aux = require('../aux');
|
|
17
|
+
bundle = require('./bundle');
|
|
17
18
|
cwd = process.cwd();
|
|
18
19
|
pugbuild = function(opt){
|
|
19
20
|
opt == null && (opt = {});
|
|
@@ -134,17 +135,19 @@ pugbuild.prototype = import$(Object.create(base.prototype), {
|
|
|
134
135
|
if (this$.bundler) {
|
|
135
136
|
this$.bundler.addSpec(spec);
|
|
136
137
|
des = this$.bundler.desPath(spec);
|
|
137
|
-
relDesMin = path.relative(this$.desdir, des.desMin);
|
|
138
|
-
relDes = path.relative(this$.desdir, des.des);
|
|
139
|
-
if (o.type === 'css') {
|
|
140
|
-
return ret += "<link rel=\"stylesheet\" type=\"text/css\" href=\"/" + relDesMin + "\"/>";
|
|
141
|
-
} else if (o.type === 'js') {
|
|
142
|
-
return ret += "<script type=\"text/javascript\" src=\"/" + relDesMin + "\"></script>";
|
|
143
|
-
} else if (o.type === 'block') {
|
|
144
|
-
return ret += "<link rel=\"block\" href=\"/" + relDesMin + "\">";
|
|
145
|
-
}
|
|
146
138
|
} else {
|
|
147
|
-
|
|
139
|
+
des = bundle.desPath(import$({
|
|
140
|
+
desdir: this$.desdir
|
|
141
|
+
}, spec));
|
|
142
|
+
}
|
|
143
|
+
relDesMin = path.relative(this$.desdir, des.desMin);
|
|
144
|
+
relDes = path.relative(this$.desdir, des.des);
|
|
145
|
+
if (o.type === 'css') {
|
|
146
|
+
return ret += "<link rel=\"stylesheet\" type=\"text/css\" href=\"/" + relDesMin + "\"/>";
|
|
147
|
+
} else if (o.type === 'js') {
|
|
148
|
+
return ret += "<script type=\"text/javascript\" src=\"/" + relDesMin + "\"></script>";
|
|
149
|
+
} else if (o.type === 'block') {
|
|
150
|
+
return ret += "<link rel=\"block\" href=\"/" + relDesMin + "\">";
|
|
148
151
|
}
|
|
149
152
|
});
|
|
150
153
|
return ret;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "zbryikt",
|
|
3
3
|
"name": "@plotdb/srcbuild",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.62",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "./dist/main.js",
|
|
7
7
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@loadingio/debounce.js": "^1.0.1",
|
|
30
|
-
"@plotdb/block": "^5.0.
|
|
30
|
+
"@plotdb/block": "^5.0.2",
|
|
31
31
|
"@plotdb/colors": "^0.0.1",
|
|
32
32
|
"anymatch": "^3.1.2",
|
|
33
33
|
"browserify": "^17.0.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@loadingio/bootstrap.ext": "^0.0.9",
|
|
52
|
-
"@plotdb/csscope": "^5.0.
|
|
53
|
-
"@plotdb/rescope": "^5.0.
|
|
52
|
+
"@plotdb/csscope": "^5.0.1",
|
|
53
|
+
"@plotdb/rescope": "^5.0.1",
|
|
54
54
|
"@plotdb/semver": "^0.0.3",
|
|
55
55
|
"@loadingio/ldquery": "^3.0.4",
|
|
56
56
|
"bootstrap": "^4.6.1",
|