@plotdb/srcbuild 0.0.30 → 0.0.34

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/CHANGELOG.md ADDED
@@ -0,0 +1,177 @@
1
+ # Change Log
2
+
3
+ ## v0.0.34
4
+
5
+ - support legacy syntax in libLoader for script loading
6
+ - fix bug: `libLoader.root` doesn't work properly
7
+
8
+
9
+ ## v0.0.33
10
+
11
+ - support relative path in bundle.json
12
+ - add test case for bundler
13
+ - use local script for testing
14
+
15
+
16
+ ## v0.0.32
17
+
18
+ - bug fix: `defer` in libLoader should be by default true.
19
+ - bug fix: stylus extension doesn't provide correct path for dependencies.
20
+
21
+
22
+ ## v0.0.31
23
+
24
+ - bug fix: the `script` and `css` mixin supports should be done by `postParse` plugin instead of code modification.
25
+
26
+
27
+ ## v0.0.30
28
+
29
+ - directly support `script` and `css` mixin in pug compiling.
30
+
31
+
32
+ ## v0.0.29
33
+
34
+ - bug fix: bundle not rebuild when bundle config file updated
35
+ - bug fix: bundler exception not caught
36
+
37
+
38
+ ## v0.0.28
39
+
40
+ - totally remove `compress` option to prevent unwanted side effect of code removal
41
+
42
+
43
+ ## v0.0.27
44
+
45
+ - dont compress unused in pug lsc filter for our potential use of custom script block design in @plotdb/block
46
+
47
+
48
+ ## v0.0.26
49
+
50
+ - remove log
51
+
52
+
53
+ ## v0.0.25
54
+
55
+ - pass `ignored` to adapter to bypass unnecessary files to save time
56
+ - by default minimize javascript and css in pug filter.
57
+
58
+
59
+ ## v0.0.24
60
+
61
+ - set `doctype` to `html` also in `pug-cli` to prevent `t="t"` generation.
62
+
63
+
64
+ ## v0.0.23
65
+
66
+ - set `doctype` to `html` to prevent `t="t"` generation.
67
+
68
+
69
+ ## v0.0.22
70
+
71
+ - add `srcbuild-pug` command for building pug with extapi
72
+ - fix yaml loading issue by using `load` instead of `safe-load`.
73
+
74
+
75
+ ## v0.0.21
76
+
77
+ - fix module resolving path bug
78
+
79
+
80
+ ## v0.0.20
81
+
82
+ - resolve module path from basedir in ext/pug.
83
+
84
+
85
+ ## v0.0.19
86
+
87
+ - bump stylus version to 0.55.0 for removing deprecated dependencies
88
+
89
+
90
+ ## v0.0.18
91
+
92
+ - fix bug: lsc builder doesn't build unless glslify is enabled
93
+
94
+
95
+ ## v0.0.17
96
+
97
+ - support `json` API for reading json file in pug
98
+
99
+
100
+ ## v0.0.16
101
+
102
+ - fix bug: glslify transformed by browserify should have basedir from src file dir.
103
+
104
+
105
+ ## v0.0.15
106
+
107
+ - upgrade `path-parse` to fix vulnerability
108
+ - support glslify transfomration by option `use-glslify`
109
+
110
+
111
+ ## v0.0.14
112
+
113
+ - add `i18n.intlbase` and `i18n.langauge` pug api and deprecate `intlbase` pug api.
114
+
115
+
116
+ ## v0.0.13
117
+
118
+ - fix bug: incorrect parameter passing in view/pug to ext/pug
119
+
120
+
121
+ ## v0.0.12
122
+
123
+ - add bundling sample code
124
+ - fix bundling file path shown in log
125
+
126
+
127
+ ## v0.0.11
128
+
129
+ - fix bug: `desdir` and `base` not passed to pug in pug view constructor
130
+
131
+
132
+ ## v0.0.10
133
+
134
+ - fix bug: basedir should be opt.basedir
135
+
136
+
137
+ ## v0.0.9
138
+
139
+ - support pug view engine for express
140
+
141
+
142
+ ## v0.0.8
143
+
144
+ - fix bug: trying to get mtime of a non-existed file.
145
+ - support options for files to ignore. by default, ignore `.git` folders.
146
+
147
+
148
+ ## v0.0.7
149
+
150
+ - simplify log
151
+
152
+
153
+ ## v0.0.6
154
+
155
+ - trap exception during `log-dependencies` and prevent from further building.
156
+ - keep old dependency if `log-dependencies` fails.
157
+
158
+
159
+ ## v0.0.5
160
+
161
+ - support bundling
162
+
163
+
164
+ ## v0.0.4
165
+
166
+ - fix bug in ext/pug: basedir doesn't exist when initing, causing problem when getting dependencies. use path.resolve(srcdir) instead.
167
+
168
+
169
+ ## v0.0.3
170
+
171
+ - fix typo
172
+
173
+
174
+ ## v0.0.2
175
+
176
+ - fix bug: let pug use correct filename and basedir parameter. resolve pug files correctly
177
+
package/README.md CHANGED
@@ -97,6 +97,10 @@ Except common options, each builder may support different options:
97
97
  - *NOTE* this is an experiment feature and may be removed ( move to standalone builder ) in the future.
98
98
  - `bundle`: bundle options. includes:
99
99
  - `configFile`: json file storing bundle configuration. optional.
100
+ - `relativePath`: use relative path for paths in config file. default false. possible values:
101
+ - `false`: all files in `configFile` are relative to current working directory.
102
+ - `true`: all files in `configFile` are relative to the directory containing `bundle.json`
103
+ - or, specific a path as the relative root.
100
104
  - `config`: bundle configuration in following format:
101
105
  {
102
106
  "css": {
@@ -16,6 +16,11 @@ bundlebuild = function(opt){
16
16
  js: {}
17
17
  };
18
18
  this.configFile = opt.configFile || null;
19
+ this._relativePath = !(opt.relativePath != null)
20
+ ? false
21
+ : typeof opt.relativePath === 'string'
22
+ ? opt.relativePath
23
+ : this.configFile ? path.dirname(this.configFile) : false;
19
24
  this.prepareConfig();
20
25
  return this.init(import$({
21
26
  srcdir: 'static',
@@ -24,10 +29,18 @@ bundlebuild = function(opt){
24
29
  };
25
30
  bundlebuild.prototype = import$(Object.create(base.prototype), {
26
31
  prepareConfig: function(){
27
- var type, name, ref$, list, i$, len$, f;
32
+ var type, name, ref$, list, i$, len$, f, this$ = this;
28
33
  if (this.configFile && fs.existsSync(this.configFile)) {
29
34
  this.config = JSON.parse(fs.readFileSync(this.configFile).toString());
30
35
  }
36
+ if (typeof this._relativePath === 'string') {
37
+ for (type in this.config) {
38
+ for (name in ref$ = this.config[type]) {
39
+ list = ref$[name];
40
+ this.config[type][name] = list.map(fn$);
41
+ }
42
+ }
43
+ }
31
44
  this.fileList = new Set();
32
45
  this.fileMap = {};
33
46
  for (type in this.config) {
@@ -44,6 +57,9 @@ bundlebuild.prototype = import$(Object.create(base.prototype), {
44
57
  }
45
58
  }
46
59
  return this.fileList.add(this.configFile);
60
+ function fn$(f){
61
+ return path.join(this$._relativePath, f);
62
+ }
47
63
  },
48
64
  getDependencies: function(file){
49
65
  return file === this.configFile
package/dist/ext/pug.js CHANGED
@@ -59,6 +59,24 @@ pugbuild.prototype = import$(Object.create(base.prototype), {
59
59
  }
60
60
  args = res$;
61
61
  return this$.pugResolve.apply(this$, args);
62
+ },
63
+ postParse: function(dom, opt){
64
+ if (dom.nodes[0].type !== 'Doctype') {
65
+ return dom;
66
+ }
67
+ dom.nodes.splice(1, 0, {
68
+ type: 'Include',
69
+ block: {
70
+ type: 'Block',
71
+ nodes: []
72
+ },
73
+ file: {
74
+ type: 'FileReference',
75
+ filename: opt.filename,
76
+ path: '@/@plotdb/srcbuild/dist/lib.pug'
77
+ }
78
+ });
79
+ return dom;
62
80
  }
63
81
  }],
64
82
  filters: {
@@ -205,7 +223,6 @@ pugbuild.prototype = import$(Object.create(base.prototype), {
205
223
  continue;
206
224
  }
207
225
  code = fs.readFileSync(src).toString();
208
- code = "include @/@plotdb/srcbuild/dist/lib.pug\n" + code;
209
226
  try {
210
227
  t1 = Date.now();
211
228
  if (/^\/\/- ?module ?/.exec(code)) {
@@ -18,7 +18,7 @@ stylusbuild = function(opt){
18
18
  };
19
19
  stylusbuild.prototype = import$(Object.create(base.prototype), {
20
20
  getDependencies: function(file){
21
- var code, ret, root;
21
+ var code, ret, root, this$ = this;
22
22
  code = fs.readFileSync(file).toString();
23
23
  ret = code.split('\n').map(function(it){
24
24
  return /\s*(@import)\s+(.+)$/.exec(it);
@@ -27,7 +27,7 @@ stylusbuild.prototype = import$(Object.create(base.prototype), {
27
27
  }).map(function(it){
28
28
  return it[2].replace(/'/g, '').replace(/(\.styl)?$/, '.styl');
29
29
  }).map(function(it){
30
- return it;
30
+ return path.join(this$.srcdir, it);
31
31
  });
32
32
  root = path.resolve('.') + '/';
33
33
  return (ret || []).map(function(it){
package/dist/lib.pug CHANGED
@@ -4,7 +4,7 @@
4
4
  libLoader = {
5
5
  js: {url: {}},
6
6
  css: {url: {}},
7
- root: function(r) { this._root = r; },
7
+ root: function(r) { libLoader._r = r; },
8
8
  _r: "/assets/lib",
9
9
  _v: "",
10
10
  version: function(v) { libLoader._v = (v ? "?v=" + v : ""); }
@@ -12,27 +12,30 @@
12
12
  if(version) { libLoader.version(version); }
13
13
  }
14
14
 
15
- mixin script(os)
15
+ mixin script(os,cfg)
16
16
  -
17
17
  if(!Array.isArray(os)) { os = [os]; }
18
18
  each o in os
19
19
  -
20
- if(typeof(o) == "string") { url = o; }
20
+ c = o;
21
+ if(typeof(o) == "string") { url = o; c = cfg || {};}
21
22
  else if(o.url) { url = o.url; }
22
23
  else { url = libLoader._r + "/" + o.name + "/" + (o.version || 'main') + "/" + (o.path || "index.min.js"); }
23
24
  if !libLoader.js.url[url]
24
25
  - libLoader.js.url[url] = true;
26
+ - defer = (typeof(c.defer) == "undefined" ? true : !!c.defer);
25
27
  if /^https?:\/\/./.exec(url)
26
- script(type="text/javascript",src=url, defer=!!o.defer, async=!!o.async)
28
+ script(type="text/javascript",src=url, defer=defer, async=!!c.async)
27
29
  else
28
- script(type="text/javascript",src=url + libLoader._v, defer=!!o.defer, async=!!o.async)
30
+ script(type="text/javascript",src=url + libLoader._v, defer=defer, async=!!c.async)
29
31
 
30
- mixin css(os)
32
+ mixin css(os,cfg)
31
33
  -
32
34
  if(!Array.isArray(os)) { os = [os]; }
33
35
  each o in os
34
36
  -
35
- if(typeof(o) == "string") { url = o; }
37
+ c = o;
38
+ if(typeof(o) == "string") { url = o; c = cfg || {};}
36
39
  else if(o.url) { url = o.url; }
37
40
  else { url = libLoader._r + "/" + o.name + "/" + (o.version || 'main') + "/" + (o.path || "index.min.css"); }
38
41
  if !libLoader.css.url[url]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "zbryikt",
3
3
  "name": "@plotdb/srcbuild",
4
- "version": "0.0.30",
4
+ "version": "0.0.34",
5
5
  "description": "",
6
6
  "main": "./dist/main.js",
7
7
  "files": [
@@ -12,7 +12,7 @@
12
12
  "srcbuild-pug": "./dist/pug-cli"
13
13
  },
14
14
  "scripts": {
15
- "start": "./dist/cli"
15
+ "start": "./node_modules/.bin/lsc watch.ls"
16
16
  },
17
17
  "license": "MIT",
18
18
  "homepage": "https://github.com/plotdb/srcbuild",