@plotdb/srcbuild 0.0.61 → 0.0.63

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 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
@@ -478,7 +478,7 @@ build.prototype = import$(Object.create(base.prototype), {
478
478
  var codesrc, specsrc, deps, ref$, ref1$;
479
479
  if (o.type === 'block') {
480
480
  return this$.mgr.bundle({
481
- blocks: o.codesrc || (o.codesrc = [])
481
+ blocks: (o.src || (o.src = [])).concat(o.codesrc || (o.codesrc = []))
482
482
  }).then(function(r){
483
483
  var deps, codesrc, specsrc, ref$, ref1$;
484
484
  if (!(r && r.deps)) {
@@ -541,18 +541,13 @@ build.prototype = import$(Object.create(base.prototype), {
541
541
  return this.specmgr.touchCode(files);
542
542
  },
543
543
  desPath: function(arg$){
544
- var name, type, _desdir, ext, des, desMin, desdir;
544
+ var name, type;
545
545
  name = arg$.name, type = arg$.type;
546
- _desdir = path.join(this.desdir, 'assets', 'bundle');
547
- ext = type === 'block' ? 'html' : type;
548
- des = path.join(_desdir, name + "." + ext);
549
- desMin = path.join(_desdir, name + ".min." + ext);
550
- desdir = path.dirname(des);
551
- return {
552
- desdir: desdir,
553
- des: des,
554
- desMin: desMin
555
- };
546
+ return build.desPath({
547
+ desdir: this.desdir,
548
+ name: name,
549
+ type: type
550
+ });
556
551
  },
557
552
  buildBySpec: function(spec){
558
553
  var this$ = this;
@@ -643,6 +638,20 @@ build.prototype = import$(Object.create(base.prototype), {
643
638
  });
644
639
  }
645
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
+ };
646
655
  module.exports = build;
647
656
  function import$(obj, src){
648
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
- return ret += "<!-- no bundler available for bundling " + name + " in type " + o.type + " -->";
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.61",
4
+ "version": "0.0.63",
5
5
  "description": "",
6
6
  "main": "./dist/main.js",
7
7
  "files": [