app-bundler 0.2.8 → 0.2.10

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.
Files changed (3) hide show
  1. package/lib/bundler.js +24 -12
  2. package/lib/cli.js +24 -12
  3. package/package.json +1 -1
package/lib/bundler.js CHANGED
@@ -2375,7 +2375,10 @@ exports.FileActions = {
2375
2375
  if (/^https?:/.test(path)) {
2376
2376
  return HttpLoader.load(path, opts);
2377
2377
  }
2378
- return global_1.io.File.readAsync(path, opts);
2378
+ return global_1.io.File.readAsync(path, {
2379
+ ...(opts !== null && opts !== void 0 ? opts : {}),
2380
+ cached: false
2381
+ });
2379
2382
  },
2380
2383
  async readDirectory(path, opts) {
2381
2384
  let i = path.indexOf('*');
@@ -5062,8 +5065,8 @@ const Resource_1 = _src_class_Resource;
5062
5065
  const Templates_1 = _src_handlers_script_common_js_templates_Templates;
5063
5066
  exports.CommonJsBuilderSimplified = {
5064
5067
  wrapModule(resource, outputItem, outputItems, setts) {
5065
- var varId = getVarId(resource);
5066
- var content = resource.content;
5068
+ let varId = getVarId(resource);
5069
+ let content = resource.content;
5067
5070
  content = replaceWithVarIds(content, resource, this.solution);
5068
5071
  content = Templates_1.Templates
5069
5072
  .ModuleSimplified
@@ -5071,7 +5074,7 @@ exports.CommonJsBuilderSimplified = {
5071
5074
  .replace(/[_]{3}MODULE[_]{3}/g, () => content)
5072
5075
  .replace(/[_]{3}FOOTER[_]{3}/g, () => { var _a, _b; return ((_b = (_a = setts === null || setts === void 0 ? void 0 : setts.partials) === null || _a === void 0 ? void 0 : _a.footer) !== null && _b !== void 0 ? _b : ''); });
5073
5076
  ;
5074
- var opts = this.solution.iteration;
5077
+ let opts = this.solution.iteration;
5075
5078
  if (opts.commonjs == null) {
5076
5079
  opts.commonjs = {
5077
5080
  addHeading: true,
@@ -5086,11 +5089,12 @@ exports.CommonJsBuilderSimplified = {
5086
5089
  return content;
5087
5090
  },
5088
5091
  getRootContent(root) {
5089
- var rootInput = this.solution.outputResources.rootInput, content = replaceWithVarIds(root.content, rootInput, this.solution);
5092
+ let rootInput = this.solution.outputResources.rootInput;
5093
+ let content = replaceWithVarIds(root.content, rootInput, this.solution);
5090
5094
  return content;
5091
5095
  },
5092
5096
  getHeaderContent() {
5093
- var resources = this
5097
+ let resources = this
5094
5098
  .solution
5095
5099
  .outputResources
5096
5100
  .items
@@ -5100,10 +5104,13 @@ exports.CommonJsBuilderSimplified = {
5100
5104
  }
5101
5105
  };
5102
5106
  function replaceWithVarIds(content, resource, solution) {
5103
- var rgx_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
5107
+ let rgx_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
5108
+ if (typeof content !== 'string') {
5109
+ return JSON.stringify(content);
5110
+ }
5104
5111
  return content.replace(rgx_REQUIRE, (full, path) => {
5105
- var res = new Resource_1.Resource({ url: path, type: 'js' }, resource, solution);
5106
- var current = resource.resources.find(x => x.url === res.url);
5112
+ let res = new Resource_1.Resource({ url: path, type: 'js' }, resource, solution);
5113
+ let current = resource.resources.find(x => x.url === res.url);
5107
5114
  if (current == null) {
5108
5115
  return full;
5109
5116
  }
@@ -5111,11 +5118,11 @@ function replaceWithVarIds(content, resource, solution) {
5111
5118
  });
5112
5119
  }
5113
5120
  function getVarId(resource) {
5114
- var str = resource.url.replace(/\.\w+$/, '');
5121
+ let str = resource.url.replace(/\.\w+$/, '');
5115
5122
  return str.replace(/[^\w\d]/g, '_');
5116
5123
  }
5117
5124
  function getModuleVars(resources) {
5118
- return resources.map(getVarId).sort().map(x => `var ${x} = {};`).join('\n') + '\n';
5125
+ return resources.map(getVarId).sort().map(x => `let ${x} = {};`).join('\n') + '\n';
5119
5126
  }
5120
5127
  //# sourceMappingURL=CommonJsBuilderSimplified.js.map
5121
5128
  //# sourceMappingURL=CommonJsBuilderSimplified.ts.map;
@@ -12222,6 +12229,7 @@ const res_1 = _src_utils_res;
12222
12229
  const tree_1 = _src_utils_tree;
12223
12230
  const Builder_1 = _src_builder_Builder;
12224
12231
  const color_1 = _src_utils_color;
12232
+ const File_1 = _src_config_File;
12225
12233
  class Bundler extends atma_utils_1.class_EventEmitter {
12226
12234
  static clearCache() {
12227
12235
  Loader_1.Loader.clearCache();
@@ -12351,7 +12359,11 @@ class Bundler extends atma_utils_1.class_EventEmitter {
12351
12359
  let solution = bundler.solution;
12352
12360
  function builderComplete(resources) {
12353
12361
  resources.forEach(res => {
12354
- global_1.io.File.write(res.filename, res.content);
12362
+ let content = res.content;
12363
+ if (typeof content !== 'string') {
12364
+ content = JSON.stringify(content, null, 2);
12365
+ }
12366
+ File_1.FileActions.writeFile(res.filename, content, { skipHooks: true });
12355
12367
  });
12356
12368
  return solution
12357
12369
  .assetsManager
package/lib/cli.js CHANGED
@@ -2377,7 +2377,10 @@ exports.FileActions = {
2377
2377
  if (/^https?:/.test(path)) {
2378
2378
  return HttpLoader.load(path, opts);
2379
2379
  }
2380
- return global_1.io.File.readAsync(path, opts);
2380
+ return global_1.io.File.readAsync(path, {
2381
+ ...(opts !== null && opts !== void 0 ? opts : {}),
2382
+ cached: false
2383
+ });
2381
2384
  },
2382
2385
  async readDirectory(path, opts) {
2383
2386
  let i = path.indexOf('*');
@@ -5064,8 +5067,8 @@ const Resource_1 = _src_class_Resource;
5064
5067
  const Templates_1 = _src_handlers_script_common_js_templates_Templates;
5065
5068
  exports.CommonJsBuilderSimplified = {
5066
5069
  wrapModule(resource, outputItem, outputItems, setts) {
5067
- var varId = getVarId(resource);
5068
- var content = resource.content;
5070
+ let varId = getVarId(resource);
5071
+ let content = resource.content;
5069
5072
  content = replaceWithVarIds(content, resource, this.solution);
5070
5073
  content = Templates_1.Templates
5071
5074
  .ModuleSimplified
@@ -5073,7 +5076,7 @@ exports.CommonJsBuilderSimplified = {
5073
5076
  .replace(/[_]{3}MODULE[_]{3}/g, () => content)
5074
5077
  .replace(/[_]{3}FOOTER[_]{3}/g, () => { var _a, _b; return ((_b = (_a = setts === null || setts === void 0 ? void 0 : setts.partials) === null || _a === void 0 ? void 0 : _a.footer) !== null && _b !== void 0 ? _b : ''); });
5075
5078
  ;
5076
- var opts = this.solution.iteration;
5079
+ let opts = this.solution.iteration;
5077
5080
  if (opts.commonjs == null) {
5078
5081
  opts.commonjs = {
5079
5082
  addHeading: true,
@@ -5088,11 +5091,12 @@ exports.CommonJsBuilderSimplified = {
5088
5091
  return content;
5089
5092
  },
5090
5093
  getRootContent(root) {
5091
- var rootInput = this.solution.outputResources.rootInput, content = replaceWithVarIds(root.content, rootInput, this.solution);
5094
+ let rootInput = this.solution.outputResources.rootInput;
5095
+ let content = replaceWithVarIds(root.content, rootInput, this.solution);
5092
5096
  return content;
5093
5097
  },
5094
5098
  getHeaderContent() {
5095
- var resources = this
5099
+ let resources = this
5096
5100
  .solution
5097
5101
  .outputResources
5098
5102
  .items
@@ -5102,10 +5106,13 @@ exports.CommonJsBuilderSimplified = {
5102
5106
  }
5103
5107
  };
5104
5108
  function replaceWithVarIds(content, resource, solution) {
5105
- var rgx_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
5109
+ let rgx_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
5110
+ if (typeof content !== 'string') {
5111
+ return JSON.stringify(content);
5112
+ }
5106
5113
  return content.replace(rgx_REQUIRE, (full, path) => {
5107
- var res = new Resource_1.Resource({ url: path, type: 'js' }, resource, solution);
5108
- var current = resource.resources.find(x => x.url === res.url);
5114
+ let res = new Resource_1.Resource({ url: path, type: 'js' }, resource, solution);
5115
+ let current = resource.resources.find(x => x.url === res.url);
5109
5116
  if (current == null) {
5110
5117
  return full;
5111
5118
  }
@@ -5113,11 +5120,11 @@ function replaceWithVarIds(content, resource, solution) {
5113
5120
  });
5114
5121
  }
5115
5122
  function getVarId(resource) {
5116
- var str = resource.url.replace(/\.\w+$/, '');
5123
+ let str = resource.url.replace(/\.\w+$/, '');
5117
5124
  return str.replace(/[^\w\d]/g, '_');
5118
5125
  }
5119
5126
  function getModuleVars(resources) {
5120
- return resources.map(getVarId).sort().map(x => `var ${x} = {};`).join('\n') + '\n';
5127
+ return resources.map(getVarId).sort().map(x => `let ${x} = {};`).join('\n') + '\n';
5121
5128
  }
5122
5129
  //# sourceMappingURL=CommonJsBuilderSimplified.js.map
5123
5130
  //# sourceMappingURL=CommonJsBuilderSimplified.ts.map;
@@ -12224,6 +12231,7 @@ const res_1 = _src_utils_res;
12224
12231
  const tree_1 = _src_utils_tree;
12225
12232
  const Builder_1 = _src_builder_Builder;
12226
12233
  const color_1 = _src_utils_color;
12234
+ const File_1 = _src_config_File;
12227
12235
  class Bundler extends atma_utils_1.class_EventEmitter {
12228
12236
  static clearCache() {
12229
12237
  Loader_1.Loader.clearCache();
@@ -12353,7 +12361,11 @@ class Bundler extends atma_utils_1.class_EventEmitter {
12353
12361
  let solution = bundler.solution;
12354
12362
  function builderComplete(resources) {
12355
12363
  resources.forEach(res => {
12356
- global_1.io.File.write(res.filename, res.content);
12364
+ let content = res.content;
12365
+ if (typeof content !== 'string') {
12366
+ content = JSON.stringify(content, null, 2);
12367
+ }
12368
+ File_1.FileActions.writeFile(res.filename, content, { skipHooks: true });
12357
12369
  });
12358
12370
  return solution
12359
12371
  .assetsManager
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-bundler",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "",
5
5
  "main": "lib/bundler.js",
6
6
  "bin": {