app-bundler 0.2.5 → 0.2.7

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 +219 -71
  2. package/lib/cli.js +219 -71
  3. package/package.json +1 -1
package/lib/bundler.js CHANGED
@@ -80,6 +80,7 @@ var _src_handlers_script_copy_js_CopyJsBuilder = {};
80
80
  var _src_handlers_script_copy_js_CopyJsHandler = {};
81
81
  var _src_handlers_script_copy_js_CopyJsParser = {};
82
82
  var _src_handlers_script_copy_js_CopyJsRewriter = {};
83
+ var _src_handlers_script_data_DataInliner = {};
83
84
  var _src_handlers_script_global_js_GlobalJsBuilder = {};
84
85
  var _src_handlers_script_global_js_GlobalJsHandler = {};
85
86
  var _src_handlers_script_global_js_GlobalJsParser = {};
@@ -168,7 +169,7 @@ var _src_utils_path;
168
169
 
169
170
  "use strict";
170
171
  Object.defineProperty(exports, "__esModule", { value: true });
171
- exports.path_toAbsolute = exports.path_changeExtension = exports.path_removeQuery = exports.path_sliceQuery = exports.path_sliceHash = exports.path_combine = exports.path_toRelative = exports.path_isRelative = exports.path_resolveUrl = exports.path_normalize = exports.path_resolveCurrent = exports.path_withProtocol = exports.path_appendQuery = exports.path_getExtension = exports.path_getFile = exports.path_getDir = void 0;
172
+ exports.path_toAbsolute = exports.path_hasExtension = exports.path_changeExtension = exports.path_removeQuery = exports.path_sliceQuery = exports.path_sliceHash = exports.path_combine = exports.path_toRelative = exports.path_isRelative = exports.path_resolveUrl = exports.path_normalize = exports.path_resolveCurrent = exports.path_withProtocol = exports.path_appendQuery = exports.path_getExtension = exports.path_getFile = exports.path_getDir = void 0;
172
173
  let isWeb = true;
173
174
  function path_getDir(path) {
174
175
  return path.substring(0, path.lastIndexOf('/') + 1);
@@ -350,9 +351,16 @@ exports.path_removeQuery = path_removeQuery;
350
351
  ;
351
352
  function path_changeExtension(path, ext) {
352
353
  let str = ext ? '.' + ext : '';
354
+ if (path_hasExtension(path) === false) {
355
+ return `${path}${str}`;
356
+ }
353
357
  return path.replace(/(\.\w+)+$/, str);
354
358
  }
355
359
  exports.path_changeExtension = path_changeExtension;
360
+ function path_hasExtension(path) {
361
+ return /\.\w+$/.test(path);
362
+ }
363
+ exports.path_hasExtension = path_hasExtension;
356
364
  function path_toAbsolute(path, parentLocation, rootLocation) {
357
365
  path = path_normalize(path);
358
366
  if (path_isRelative(path) === false) {
@@ -1085,13 +1093,13 @@ function async_whenAll(mix) {
1085
1093
  }
1086
1094
  exports.async_whenAll = async_whenAll;
1087
1095
  ;
1088
- function async_resolve(...args) {
1089
- return (new atma_utils_1.class_Dfr()).resolve(...args);
1096
+ function async_resolve(result) {
1097
+ return (new atma_utils_1.class_Dfr()).resolve(result);
1090
1098
  }
1091
1099
  exports.async_resolve = async_resolve;
1092
1100
  ;
1093
- function async_reject(...args) {
1094
- return (new atma_utils_1.class_Dfr()).reject(...args);
1101
+ function async_reject(error) {
1102
+ return (new atma_utils_1.class_Dfr()).reject(error);
1095
1103
  }
1096
1104
  exports.async_reject = async_reject;
1097
1105
  ;
@@ -1100,7 +1108,7 @@ function async_run(fn) {
1100
1108
  var result = fn();
1101
1109
  if (result && result.then)
1102
1110
  return result;
1103
- return async_resolve();
1111
+ return async_resolve(null);
1104
1112
  }
1105
1113
  return atma_utils_1.class_Dfr.run((resolve, reject) => {
1106
1114
  fn(resolve, reject);
@@ -2619,19 +2627,21 @@ class SolutionOpts extends SolutionOptsBase {
2619
2627
  outputSources: '{output}/build/{build}',
2620
2628
  outputAssets: '{output}/build/{build}/assets',
2621
2629
  outputShareBase: null,
2630
+ outputExtension: 'js',
2622
2631
  package: {
2623
2632
  module: 'commonjs',
2624
2633
  modules: ['commonjs', 'includejs', 'global', 'import'],
2625
2634
  type: 'module',
2626
2635
  types: ['module', 'bundle'],
2627
2636
  moduleWrapper: 'iif',
2628
- moduleWrappers: ['umd', 'iif', 'script', 'custom'],
2637
+ moduleWrappers: ['umd', 'esm', 'iif', 'script', 'custom'],
2629
2638
  moduleName: '',
2630
2639
  import: null,
2631
2640
  },
2632
2641
  extensions: {
2633
2642
  '': { type: 'js' },
2634
2643
  'js': { type: 'js' },
2644
+ 'mjs': { type: 'js' },
2635
2645
  'es6': { type: 'js' },
2636
2646
  'jsx': { type: 'js' },
2637
2647
  'ts': { type: 'js' },
@@ -3006,6 +3016,7 @@ class OutputResources {
3006
3016
  this.items = [];
3007
3017
  this.resources = [];
3008
3018
  this.pagesInput = {};
3019
+ this.dynamicDependencies = [];
3009
3020
  }
3010
3021
  prepare(resources) {
3011
3022
  this.resources = [];
@@ -3049,6 +3060,22 @@ class OutputResources {
3049
3060
  });
3050
3061
  });
3051
3062
  }
3063
+ addDynamicDependency(dep) {
3064
+ let has = this.dynamicDependencies.some(x => x.url === dep.url);
3065
+ if (has === false) {
3066
+ this.dynamicDependencies.push(dep);
3067
+ }
3068
+ }
3069
+ remove(resource) {
3070
+ for (let i = 0; i < this.items.length; i++) {
3071
+ let item = this.items[i];
3072
+ let itemResource = item.resources.find(x => x.filename === resource.filename);
3073
+ if (itemResource !== null) {
3074
+ let idx = item.resources.indexOf(itemResource);
3075
+ item.resources.splice(idx, 1);
3076
+ }
3077
+ }
3078
+ }
3052
3079
  getForPage(page) {
3053
3080
  return this.items.filter(x => x.page === page).map(x => x.resource);
3054
3081
  }
@@ -4535,13 +4562,14 @@ const Include_1 = _src_class_Include;
4535
4562
  const BaseParser_1 = _src_handlers_base_BaseParser;
4536
4563
  const atma_utils_1 = require("atma-utils");
4537
4564
  class CommonJsParser extends BaseParser_1.BaseParser {
4538
- async transpile(content, resource) {
4539
- if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
4540
- let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
4541
- str = `module.exports = ${str};`;
4542
- return { content: str };
4543
- }
4544
- }
4565
+ // async transpile(content: any, resource: Resource): Promise<{ content: string; }> {
4566
+ // // we will inline the content instead
4567
+ // if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
4568
+ // let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
4569
+ // str = `module.exports = ${str};`;
4570
+ // return { content: str };
4571
+ // }
4572
+ // }
4545
4573
  getDependencies(ast, ownerResource) {
4546
4574
  let info = {
4547
4575
  dependencies: []
@@ -4956,39 +4984,20 @@ var __register, __require, require;
4956
4984
  // end:source ./UMD.js
4957
4985
  `,
4958
4986
  ESM: `
4959
- // source ./UMD.js
4960
- (function (factory) {
4987
+ // source ./ESM.js
4988
+ $CUSTOM_IMPORTS_CODE$
4961
4989
 
4962
- var _name = '%NAME%',
4963
- _global = typeof window === 'undefined' ? global : window,
4964
- _module = {
4965
- exports: {}
4966
- };
4967
-
4968
- factory(_module, _module.exports, _global);
4969
-
4970
- if (typeof module === 'object' && module.exports) {
4971
- module.exports = _module.exports;
4972
- }
4973
-
4974
- if (typeof define === 'function' && define.amd) {
4975
- define([], function () {
4976
- return _module.exports;
4977
- });
4978
- return;
4979
- }
4980
-
4981
- if (_name) {
4982
- _global[_name] = _module.exports;
4983
- }
4990
+ var module = {
4991
+ exports: {}
4992
+ };
4984
4993
 
4985
- }(function (module, exports, global) {
4994
+ $MODULE$
4986
4995
 
4987
- %MODULE%
4996
+ export default module.exports;
4988
4997
 
4989
- }));
4998
+ $CUSTOM_EXPORTS_CODE$
4990
4999
 
4991
- // end:source ./UMD.js
5000
+ // end:source ./ESM.js
4992
5001
  `,
4993
5002
  Style: `
4994
5003
  // source ./Style.js
@@ -5244,7 +5253,7 @@ class ModuleWrapper {
5244
5253
  this.solution = solution;
5245
5254
  }
5246
5255
  wrap(body) {
5247
- var wrapper = this.solution.opts.package.moduleWrapper;
5256
+ let wrapper = this.solution.opts.package.moduleWrapper;
5248
5257
  switch (wrapper) {
5249
5258
  case 'script':
5250
5259
  body = this.wrapSimple(body);
@@ -5277,18 +5286,43 @@ class ModuleWrapper {
5277
5286
  .replace('%BUNDLE%', () => body);
5278
5287
  }
5279
5288
  wrapWithUMD(body) {
5280
- var opts = this.solution.opts.package;
5281
- var name = opts.moduleName || '';
5289
+ let opts = this.solution.opts.package;
5290
+ let name = opts.moduleName || '';
5282
5291
  return Templates_1.Templates
5283
5292
  .UMD
5284
5293
  .replace('%MODULE%', () => body)
5285
5294
  .replace('%NAME%', () => name);
5286
5295
  }
5287
5296
  wrapWithESM(body) {
5288
- var opts = this.solution.opts.package;
5289
- var exportsCode = opts.moduleExportsCode || '';
5297
+ let opts = this.solution.opts.package;
5298
+ let exportsCode = opts.moduleExportsCode || '';
5299
+ let importsCode = opts.moduleImportsCode || '';
5300
+ let deps = this.solution.outputResources.dynamicDependencies;
5301
+ if (deps.length > 0) {
5302
+ let arr = deps.map(dep => {
5303
+ let key = `bundlerDynamic_${dep.url.replace(/[^\w]/g, '_')}`;
5304
+ return {
5305
+ url: dep.url,
5306
+ key
5307
+ };
5308
+ });
5309
+ let strImports = arr.map(item => `import ${item.key} from '${item.url}';`).join('\n');
5310
+ let strCollection = `const bundlerDynamicRepository = {};\n`
5311
+ + arr.map(item => `bundlerDynamicRepository['${item.url}'] = ${item.key};`)
5312
+ .join('\n');
5313
+ let strRequire = [
5314
+ `var bundlerOriginalRequire = require || function (url) { throw new Error('Not found: ' + url); };`,
5315
+ `var require = function (url) { return bundlerDynamicRepository[url] || bundlerOriginalRequire(url); };`
5316
+ ].join('\n');
5317
+ importsCode = [
5318
+ strImports,
5319
+ strCollection,
5320
+ strRequire
5321
+ ].join('\n');
5322
+ }
5290
5323
  return Templates_1.Templates
5291
5324
  .ESM
5325
+ .replace('$CUSTOM_IMPORTS_CODE$', () => importsCode)
5292
5326
  .replace('$CUSTOM_EXPORTS_CODE$', () => exportsCode)
5293
5327
  .replace('$MODULE$', () => body);
5294
5328
  }
@@ -6851,13 +6885,13 @@ const ResourceInfo_1 = _src_class_ResourceInfo;
6851
6885
  let Rgx = {
6852
6886
  Imports: {
6853
6887
  full: {
6854
- rgx: /^[ \t]*import\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6888
+ rgx: /^[ \t]*import\s*(\*\s+as\s+\w+\s+from\s+)?['"](?<path>[^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6855
6889
  map(match) {
6856
6890
  let $import = new ResourceInfo_1.ImportNode();
6857
6891
  $import.position = match.index;
6858
6892
  $import.length = match[0].length;
6859
6893
  $import.type = 'full';
6860
- $import.path = match[1];
6894
+ $import.path = match.groups.path;
6861
6895
  return $import;
6862
6896
  }
6863
6897
  },
@@ -6873,6 +6907,17 @@ let Rgx = {
6873
6907
  return $import;
6874
6908
  }
6875
6909
  },
6910
+ defaults: {
6911
+ rgx: /^[ \t]*import\s+(?<def>\w+)\s+from\s*['"](?<path>[^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6912
+ map(match) {
6913
+ let $import = new ResourceInfo_1.ImportNode();
6914
+ $import.position = match.index;
6915
+ $import.length = match[0].length;
6916
+ $import.type = 'full';
6917
+ $import.path = match.groups.path;
6918
+ return $import;
6919
+ }
6920
+ },
6876
6921
  exportAll: {
6877
6922
  rgx: /^[ \t]*export\s+\*\s+from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6878
6923
  map(match) {
@@ -7056,17 +7101,18 @@ class ImportJsParser extends BaseParser_1.BaseParser {
7056
7101
  /** @TODO: set to false and handle ast in ScriptParser */
7057
7102
  this.asText = true;
7058
7103
  }
7059
- async transpile(content, resource) {
7060
- if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
7061
- let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
7062
- str = [
7063
- `const data = ${str};`,
7064
- `export default data;`
7065
- ].join('\n');
7066
- return { content: str };
7067
- }
7068
- }
7069
- getDependencies(content, ownerResource) {
7104
+ // async transpile(content: any, resource: Resource): Promise<{ content: string; }> {
7105
+ // // we will inline the content instead
7106
+ // if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
7107
+ // let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
7108
+ // str = [
7109
+ // `const data = ${str};`,
7110
+ // `export default data;`
7111
+ // ].join('\n');
7112
+ // return { content: str };
7113
+ // }
7114
+ // }
7115
+ async getDependencies(content, ownerResource) {
7070
7116
  if (Parser_1.Parser.supports(content) === false) {
7071
7117
  return null;
7072
7118
  }
@@ -7725,6 +7771,10 @@ class ScriptParser extends BaseParser_1.BaseParser {
7725
7771
  if (!content) {
7726
7772
  throw new Error(`Content is undefined for ${ownerResource.filename}`);
7727
7773
  }
7774
+ if (typeof content !== 'string') {
7775
+ // The data content is loaded as json
7776
+ return Promise.resolve({ dependencies: [] });
7777
+ }
7728
7778
  let opts = {
7729
7779
  filename: ownerResource.filename
7730
7780
  };
@@ -7784,6 +7834,80 @@ exports.ScriptParser = ScriptParser;
7784
7834
  // end:source ./ModuleSimplified.js
7785
7835
 
7786
7836
 
7837
+ // source ./ModuleSimplified.js
7838
+ var _src_handlers_script_data_DataInliner;
7839
+ (function () {
7840
+ // ensure AMD is not active for the model, so that any UMD exports as commonjs
7841
+ var define = null;
7842
+ var exports = _src_handlers_script_data_DataInliner != null ? _src_handlers_script_data_DataInliner : {};
7843
+ var module = { exports: exports };
7844
+
7845
+ "use strict";
7846
+ Object.defineProperty(exports, "__esModule", { value: true });
7847
+ exports.DataInliner = void 0;
7848
+ const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
7849
+ class DataInliner extends BaseRewriter_1.BaseRewriter {
7850
+ rewriteRoot(resourceInput, resourceOutput) {
7851
+ }
7852
+ rewritePartial(content, ownerResource) {
7853
+ }
7854
+ async rewriteResource(resource) {
7855
+ for (let res of resource.dependencies) {
7856
+ if (/(json|yml)$/.test(res.url) === false) {
7857
+ continue;
7858
+ }
7859
+ if (res.import != null) {
7860
+ await this.rewriteImport(resource, res);
7861
+ continue;
7862
+ }
7863
+ console.error('CJS not implemented');
7864
+ }
7865
+ }
7866
+ accepts(type) {
7867
+ return type === 'js';
7868
+ }
7869
+ rewriteImport(resource, dep) {
7870
+ let rgx = new RegExp(`import\\s+(?<name>[\\w_$]+)\\s+from\\s+['"]${dep.url}['"];?`);
7871
+ let match = rgx.exec(resource.content);
7872
+ if (match == null) {
7873
+ console.error(`No data import found for ${dep.url} in ${resource.filename}`);
7874
+ return;
7875
+ }
7876
+ let name = match.groups.name;
7877
+ let json = dep.resource.content;
7878
+ if (typeof json !== 'string') {
7879
+ json = JSON.stringify(json);
7880
+ }
7881
+ let code = `const ${name} = ${json}`;
7882
+ let content = resource.content.replace(match[0], code);
7883
+ resource.content = content;
7884
+ let i = resource.dependencies.indexOf(dep);
7885
+ resource.dependencies.splice(i, 1);
7886
+ this.solution.outputResources.remove(dep.resource);
7887
+ }
7888
+ }
7889
+ exports.DataInliner = DataInliner;
7890
+ ;
7891
+ //# sourceMappingURL=DataInliner.js.map
7892
+ //# sourceMappingURL=DataInliner.ts.map;
7893
+
7894
+ function __isObj(x) {
7895
+ return x != null && typeof x === 'object' && x.constructor === Object;
7896
+ }
7897
+ if (_src_handlers_script_data_DataInliner === module.exports) {
7898
+ // do nothing if
7899
+ } else if (__isObj(_src_handlers_script_data_DataInliner) && __isObj(module.exports)) {
7900
+ Object.assign(_src_handlers_script_data_DataInliner, module.exports);
7901
+ } else {
7902
+ _src_handlers_script_data_DataInliner = module.exports;
7903
+ }
7904
+
7905
+ ;
7906
+ }());
7907
+
7908
+ // end:source ./ModuleSimplified.js
7909
+
7910
+
7787
7911
  // source ./ModuleSimplified.js
7788
7912
  var _src_handlers_script_ScriptRewriter;
7789
7913
  (function () {
@@ -7797,18 +7921,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
7797
7921
  exports.ScriptRewriter = void 0;
7798
7922
  const IncludeJsHandler_1 = _src_handlers_script_include_js_IncludeJsHandler;
7799
7923
  const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
7924
+ const DataInliner_1 = _src_handlers_script_data_DataInliner;
7800
7925
  class ScriptRewriter extends BaseRewriter_1.BaseRewriter {
7801
7926
  constructor() {
7802
7927
  super(...arguments);
7803
7928
  this.rewriters = [
7804
- new IncludeJsHandler_1.IncludeJsHandler.Rewriter(this.solution, this.handler)
7929
+ new IncludeJsHandler_1.IncludeJsHandler.Rewriter(this.solution, this.handler),
7930
+ new DataInliner_1.DataInliner(this.solution, this.handler),
7805
7931
  ];
7806
7932
  }
7807
7933
  rewritePartial(content, ownerResource) {
7808
7934
  }
7809
7935
  rewriteResource(resource) {
7810
- this.rewriters.forEach(rewriter => {
7811
- rewriter.rewriteResource(resource);
7936
+ return this.rewriters.map(rewriter => {
7937
+ return rewriter.rewriteResource(resource);
7812
7938
  });
7813
7939
  }
7814
7940
  accepts(type) {
@@ -8413,6 +8539,9 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8413
8539
  return;
8414
8540
  }
8415
8541
  if (dep.resource.filename.startsWith(appBase) === false) {
8542
+ // if (path_hasExtension(dep.url) === false) {
8543
+ // rewriteToRelativeUrls[dep.url] = dep.url + '.' + this.solution.opts.outputExtension;
8544
+ // }
8416
8545
  // is project dependency
8417
8546
  return;
8418
8547
  }
@@ -8420,17 +8549,17 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8420
8549
  if (relativePath == null || /(..\/)*?\/?node_modules/.test(relativePath)) {
8421
8550
  return;
8422
8551
  }
8423
- relativePath = (0, path_1.path_changeExtension)(relativePath, null);
8552
+ relativePath = (0, path_1.path_changeExtension)(relativePath, this.solution.opts.outputExtension);
8424
8553
  relativePath = relativePath.startsWith('.')
8425
8554
  ? relativePath
8426
8555
  : './' + relativePath;
8427
8556
  rewriteToRelativeUrls[dep.url] = relativePath;
8428
8557
  })
8429
8558
  .toArray();
8430
- resource.content = rewriteUrls(resource.content, rewriteToRelativeUrls);
8559
+ resource.content = rewriteUrls(resource, rewriteToRelativeUrls);
8431
8560
  }
8432
8561
  let result = [
8433
- createOutputItem(cloneWithExtension(resource, 'js'))
8562
+ createOutputItem(cloneWithExtension(resource, this.solution.opts.outputExtension))
8434
8563
  ];
8435
8564
  let extra = [{
8436
8565
  ext: 'ts.map',
@@ -8442,8 +8571,14 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8442
8571
  let readFile = Configuration_1.Configuration.Instance.get('readFile');
8443
8572
  await (0, alot_1.default)(extra).forEachAsync(async (x) => {
8444
8573
  let cloned = cloneWithExtension(resource, x.ext);
8445
- cloned.content = await readFile(cloned.filename);
8446
- cloned.content = rewriteUrls(cloned.content, rewriteToRelativeUrls);
8574
+ try {
8575
+ cloned.content = await readFile(cloned.filename);
8576
+ }
8577
+ catch (e) {
8578
+ console.error(`Error loading ${resource.filename} from ${parent.resource.filename}`);
8579
+ throw e;
8580
+ }
8581
+ cloned.content = rewriteUrls(cloned, rewriteToRelativeUrls);
8447
8582
  result.push(createOutputItem(cloneWithExtension(cloned, x.output)));
8448
8583
  if (x.ext === 'ts.map' && cloned.content != null) {
8449
8584
  let outputItem = result[result.length - 1];
@@ -8470,9 +8605,16 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8470
8605
  cloned.url = (0, path_1.path_changeExtension)(cloned.url, ext);
8471
8606
  return cloned;
8472
8607
  }
8473
- function rewriteUrls(content, rewriteToRelativeUrls) {
8608
+ function rewriteUrls(resource, rewriteToRelativeUrls) {
8609
+ let content = resource.content;
8610
+ if (content == null) {
8611
+ console.error(`<rewrite urls> No content for ${resource.filename}`);
8612
+ return '';
8613
+ }
8474
8614
  for (let key in rewriteToRelativeUrls) {
8475
- content = content.replaceAll(key, rewriteToRelativeUrls[key]);
8615
+ content = content
8616
+ .replaceAll(`"${key}"`, `"${rewriteToRelativeUrls[key]}"`)
8617
+ .replaceAll(`'${key}'`, `'${rewriteToRelativeUrls[key]}'`);
8476
8618
  }
8477
8619
  return content;
8478
8620
  }
@@ -11435,7 +11577,13 @@ function getDependenciesExternal(deps, resource, solution) {
11435
11577
  .then(() => deps);
11436
11578
  }
11437
11579
  function filterDynamicDeps(info, solution) {
11438
- info.dependencies = info.dependencies.filter(dep => isDynamicDependency(dep, solution) === false);
11580
+ info.dependencies = info.dependencies.filter(dep => {
11581
+ let isDynamic = isDynamicDependency(dep, solution);
11582
+ if (isDynamic) {
11583
+ solution.outputResources.addDynamicDependency(dep);
11584
+ }
11585
+ return isDynamic === false;
11586
+ });
11439
11587
  return info;
11440
11588
  }
11441
11589
  function isDynamicDependency(dep, solution) {
package/lib/cli.js CHANGED
@@ -82,6 +82,7 @@ var _src_handlers_script_copy_js_CopyJsBuilder = {};
82
82
  var _src_handlers_script_copy_js_CopyJsHandler = {};
83
83
  var _src_handlers_script_copy_js_CopyJsParser = {};
84
84
  var _src_handlers_script_copy_js_CopyJsRewriter = {};
85
+ var _src_handlers_script_data_DataInliner = {};
85
86
  var _src_handlers_script_global_js_GlobalJsBuilder = {};
86
87
  var _src_handlers_script_global_js_GlobalJsHandler = {};
87
88
  var _src_handlers_script_global_js_GlobalJsParser = {};
@@ -170,7 +171,7 @@ var _src_utils_path;
170
171
 
171
172
  "use strict";
172
173
  Object.defineProperty(exports, "__esModule", { value: true });
173
- exports.path_toAbsolute = exports.path_changeExtension = exports.path_removeQuery = exports.path_sliceQuery = exports.path_sliceHash = exports.path_combine = exports.path_toRelative = exports.path_isRelative = exports.path_resolveUrl = exports.path_normalize = exports.path_resolveCurrent = exports.path_withProtocol = exports.path_appendQuery = exports.path_getExtension = exports.path_getFile = exports.path_getDir = void 0;
174
+ exports.path_toAbsolute = exports.path_hasExtension = exports.path_changeExtension = exports.path_removeQuery = exports.path_sliceQuery = exports.path_sliceHash = exports.path_combine = exports.path_toRelative = exports.path_isRelative = exports.path_resolveUrl = exports.path_normalize = exports.path_resolveCurrent = exports.path_withProtocol = exports.path_appendQuery = exports.path_getExtension = exports.path_getFile = exports.path_getDir = void 0;
174
175
  let isWeb = true;
175
176
  function path_getDir(path) {
176
177
  return path.substring(0, path.lastIndexOf('/') + 1);
@@ -352,9 +353,16 @@ exports.path_removeQuery = path_removeQuery;
352
353
  ;
353
354
  function path_changeExtension(path, ext) {
354
355
  let str = ext ? '.' + ext : '';
356
+ if (path_hasExtension(path) === false) {
357
+ return `${path}${str}`;
358
+ }
355
359
  return path.replace(/(\.\w+)+$/, str);
356
360
  }
357
361
  exports.path_changeExtension = path_changeExtension;
362
+ function path_hasExtension(path) {
363
+ return /\.\w+$/.test(path);
364
+ }
365
+ exports.path_hasExtension = path_hasExtension;
358
366
  function path_toAbsolute(path, parentLocation, rootLocation) {
359
367
  path = path_normalize(path);
360
368
  if (path_isRelative(path) === false) {
@@ -1087,13 +1095,13 @@ function async_whenAll(mix) {
1087
1095
  }
1088
1096
  exports.async_whenAll = async_whenAll;
1089
1097
  ;
1090
- function async_resolve(...args) {
1091
- return (new atma_utils_1.class_Dfr()).resolve(...args);
1098
+ function async_resolve(result) {
1099
+ return (new atma_utils_1.class_Dfr()).resolve(result);
1092
1100
  }
1093
1101
  exports.async_resolve = async_resolve;
1094
1102
  ;
1095
- function async_reject(...args) {
1096
- return (new atma_utils_1.class_Dfr()).reject(...args);
1103
+ function async_reject(error) {
1104
+ return (new atma_utils_1.class_Dfr()).reject(error);
1097
1105
  }
1098
1106
  exports.async_reject = async_reject;
1099
1107
  ;
@@ -1102,7 +1110,7 @@ function async_run(fn) {
1102
1110
  var result = fn();
1103
1111
  if (result && result.then)
1104
1112
  return result;
1105
- return async_resolve();
1113
+ return async_resolve(null);
1106
1114
  }
1107
1115
  return atma_utils_1.class_Dfr.run((resolve, reject) => {
1108
1116
  fn(resolve, reject);
@@ -2621,19 +2629,21 @@ class SolutionOpts extends SolutionOptsBase {
2621
2629
  outputSources: '{output}/build/{build}',
2622
2630
  outputAssets: '{output}/build/{build}/assets',
2623
2631
  outputShareBase: null,
2632
+ outputExtension: 'js',
2624
2633
  package: {
2625
2634
  module: 'commonjs',
2626
2635
  modules: ['commonjs', 'includejs', 'global', 'import'],
2627
2636
  type: 'module',
2628
2637
  types: ['module', 'bundle'],
2629
2638
  moduleWrapper: 'iif',
2630
- moduleWrappers: ['umd', 'iif', 'script', 'custom'],
2639
+ moduleWrappers: ['umd', 'esm', 'iif', 'script', 'custom'],
2631
2640
  moduleName: '',
2632
2641
  import: null,
2633
2642
  },
2634
2643
  extensions: {
2635
2644
  '': { type: 'js' },
2636
2645
  'js': { type: 'js' },
2646
+ 'mjs': { type: 'js' },
2637
2647
  'es6': { type: 'js' },
2638
2648
  'jsx': { type: 'js' },
2639
2649
  'ts': { type: 'js' },
@@ -3008,6 +3018,7 @@ class OutputResources {
3008
3018
  this.items = [];
3009
3019
  this.resources = [];
3010
3020
  this.pagesInput = {};
3021
+ this.dynamicDependencies = [];
3011
3022
  }
3012
3023
  prepare(resources) {
3013
3024
  this.resources = [];
@@ -3051,6 +3062,22 @@ class OutputResources {
3051
3062
  });
3052
3063
  });
3053
3064
  }
3065
+ addDynamicDependency(dep) {
3066
+ let has = this.dynamicDependencies.some(x => x.url === dep.url);
3067
+ if (has === false) {
3068
+ this.dynamicDependencies.push(dep);
3069
+ }
3070
+ }
3071
+ remove(resource) {
3072
+ for (let i = 0; i < this.items.length; i++) {
3073
+ let item = this.items[i];
3074
+ let itemResource = item.resources.find(x => x.filename === resource.filename);
3075
+ if (itemResource !== null) {
3076
+ let idx = item.resources.indexOf(itemResource);
3077
+ item.resources.splice(idx, 1);
3078
+ }
3079
+ }
3080
+ }
3054
3081
  getForPage(page) {
3055
3082
  return this.items.filter(x => x.page === page).map(x => x.resource);
3056
3083
  }
@@ -4537,13 +4564,14 @@ const Include_1 = _src_class_Include;
4537
4564
  const BaseParser_1 = _src_handlers_base_BaseParser;
4538
4565
  const atma_utils_1 = require("atma-utils");
4539
4566
  class CommonJsParser extends BaseParser_1.BaseParser {
4540
- async transpile(content, resource) {
4541
- if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
4542
- let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
4543
- str = `module.exports = ${str};`;
4544
- return { content: str };
4545
- }
4546
- }
4567
+ // async transpile(content: any, resource: Resource): Promise<{ content: string; }> {
4568
+ // // we will inline the content instead
4569
+ // if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
4570
+ // let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
4571
+ // str = `module.exports = ${str};`;
4572
+ // return { content: str };
4573
+ // }
4574
+ // }
4547
4575
  getDependencies(ast, ownerResource) {
4548
4576
  let info = {
4549
4577
  dependencies: []
@@ -4958,39 +4986,20 @@ var __register, __require, require;
4958
4986
  // end:source ./UMD.js
4959
4987
  `,
4960
4988
  ESM: `
4961
- // source ./UMD.js
4962
- (function (factory) {
4989
+ // source ./ESM.js
4990
+ $CUSTOM_IMPORTS_CODE$
4963
4991
 
4964
- var _name = '%NAME%',
4965
- _global = typeof window === 'undefined' ? global : window,
4966
- _module = {
4967
- exports: {}
4968
- };
4969
-
4970
- factory(_module, _module.exports, _global);
4971
-
4972
- if (typeof module === 'object' && module.exports) {
4973
- module.exports = _module.exports;
4974
- }
4975
-
4976
- if (typeof define === 'function' && define.amd) {
4977
- define([], function () {
4978
- return _module.exports;
4979
- });
4980
- return;
4981
- }
4982
-
4983
- if (_name) {
4984
- _global[_name] = _module.exports;
4985
- }
4992
+ var module = {
4993
+ exports: {}
4994
+ };
4986
4995
 
4987
- }(function (module, exports, global) {
4996
+ $MODULE$
4988
4997
 
4989
- %MODULE%
4998
+ export default module.exports;
4990
4999
 
4991
- }));
5000
+ $CUSTOM_EXPORTS_CODE$
4992
5001
 
4993
- // end:source ./UMD.js
5002
+ // end:source ./ESM.js
4994
5003
  `,
4995
5004
  Style: `
4996
5005
  // source ./Style.js
@@ -5246,7 +5255,7 @@ class ModuleWrapper {
5246
5255
  this.solution = solution;
5247
5256
  }
5248
5257
  wrap(body) {
5249
- var wrapper = this.solution.opts.package.moduleWrapper;
5258
+ let wrapper = this.solution.opts.package.moduleWrapper;
5250
5259
  switch (wrapper) {
5251
5260
  case 'script':
5252
5261
  body = this.wrapSimple(body);
@@ -5279,18 +5288,43 @@ class ModuleWrapper {
5279
5288
  .replace('%BUNDLE%', () => body);
5280
5289
  }
5281
5290
  wrapWithUMD(body) {
5282
- var opts = this.solution.opts.package;
5283
- var name = opts.moduleName || '';
5291
+ let opts = this.solution.opts.package;
5292
+ let name = opts.moduleName || '';
5284
5293
  return Templates_1.Templates
5285
5294
  .UMD
5286
5295
  .replace('%MODULE%', () => body)
5287
5296
  .replace('%NAME%', () => name);
5288
5297
  }
5289
5298
  wrapWithESM(body) {
5290
- var opts = this.solution.opts.package;
5291
- var exportsCode = opts.moduleExportsCode || '';
5299
+ let opts = this.solution.opts.package;
5300
+ let exportsCode = opts.moduleExportsCode || '';
5301
+ let importsCode = opts.moduleImportsCode || '';
5302
+ let deps = this.solution.outputResources.dynamicDependencies;
5303
+ if (deps.length > 0) {
5304
+ let arr = deps.map(dep => {
5305
+ let key = `bundlerDynamic_${dep.url.replace(/[^\w]/g, '_')}`;
5306
+ return {
5307
+ url: dep.url,
5308
+ key
5309
+ };
5310
+ });
5311
+ let strImports = arr.map(item => `import ${item.key} from '${item.url}';`).join('\n');
5312
+ let strCollection = `const bundlerDynamicRepository = {};\n`
5313
+ + arr.map(item => `bundlerDynamicRepository['${item.url}'] = ${item.key};`)
5314
+ .join('\n');
5315
+ let strRequire = [
5316
+ `var bundlerOriginalRequire = require || function (url) { throw new Error('Not found: ' + url); };`,
5317
+ `var require = function (url) { return bundlerDynamicRepository[url] || bundlerOriginalRequire(url); };`
5318
+ ].join('\n');
5319
+ importsCode = [
5320
+ strImports,
5321
+ strCollection,
5322
+ strRequire
5323
+ ].join('\n');
5324
+ }
5292
5325
  return Templates_1.Templates
5293
5326
  .ESM
5327
+ .replace('$CUSTOM_IMPORTS_CODE$', () => importsCode)
5294
5328
  .replace('$CUSTOM_EXPORTS_CODE$', () => exportsCode)
5295
5329
  .replace('$MODULE$', () => body);
5296
5330
  }
@@ -6853,13 +6887,13 @@ const ResourceInfo_1 = _src_class_ResourceInfo;
6853
6887
  let Rgx = {
6854
6888
  Imports: {
6855
6889
  full: {
6856
- rgx: /^[ \t]*import\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6890
+ rgx: /^[ \t]*import\s*(\*\s+as\s+\w+\s+from\s+)?['"](?<path>[^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6857
6891
  map(match) {
6858
6892
  let $import = new ResourceInfo_1.ImportNode();
6859
6893
  $import.position = match.index;
6860
6894
  $import.length = match[0].length;
6861
6895
  $import.type = 'full';
6862
- $import.path = match[1];
6896
+ $import.path = match.groups.path;
6863
6897
  return $import;
6864
6898
  }
6865
6899
  },
@@ -6875,6 +6909,17 @@ let Rgx = {
6875
6909
  return $import;
6876
6910
  }
6877
6911
  },
6912
+ defaults: {
6913
+ rgx: /^[ \t]*import\s+(?<def>\w+)\s+from\s*['"](?<path>[^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6914
+ map(match) {
6915
+ let $import = new ResourceInfo_1.ImportNode();
6916
+ $import.position = match.index;
6917
+ $import.length = match[0].length;
6918
+ $import.type = 'full';
6919
+ $import.path = match.groups.path;
6920
+ return $import;
6921
+ }
6922
+ },
6878
6923
  exportAll: {
6879
6924
  rgx: /^[ \t]*export\s+\*\s+from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
6880
6925
  map(match) {
@@ -7058,17 +7103,18 @@ class ImportJsParser extends BaseParser_1.BaseParser {
7058
7103
  /** @TODO: set to false and handle ast in ScriptParser */
7059
7104
  this.asText = true;
7060
7105
  }
7061
- async transpile(content, resource) {
7062
- if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
7063
- let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
7064
- str = [
7065
- `const data = ${str};`,
7066
- `export default data;`
7067
- ].join('\n');
7068
- return { content: str };
7069
- }
7070
- }
7071
- getDependencies(content, ownerResource) {
7106
+ // async transpile(content: any, resource: Resource): Promise<{ content: string; }> {
7107
+ // // we will inline the content instead
7108
+ // if (/\.(yml|json)([^\w]|$)/.test(resource.filename)) {
7109
+ // let str = typeof content !== 'string' ? JSON.stringify(content, null, ' ') : content;
7110
+ // str = [
7111
+ // `const data = ${str};`,
7112
+ // `export default data;`
7113
+ // ].join('\n');
7114
+ // return { content: str };
7115
+ // }
7116
+ // }
7117
+ async getDependencies(content, ownerResource) {
7072
7118
  if (Parser_1.Parser.supports(content) === false) {
7073
7119
  return null;
7074
7120
  }
@@ -7727,6 +7773,10 @@ class ScriptParser extends BaseParser_1.BaseParser {
7727
7773
  if (!content) {
7728
7774
  throw new Error(`Content is undefined for ${ownerResource.filename}`);
7729
7775
  }
7776
+ if (typeof content !== 'string') {
7777
+ // The data content is loaded as json
7778
+ return Promise.resolve({ dependencies: [] });
7779
+ }
7730
7780
  let opts = {
7731
7781
  filename: ownerResource.filename
7732
7782
  };
@@ -7786,6 +7836,80 @@ exports.ScriptParser = ScriptParser;
7786
7836
  // end:source ./ModuleSimplified.js
7787
7837
 
7788
7838
 
7839
+ // source ./ModuleSimplified.js
7840
+ var _src_handlers_script_data_DataInliner;
7841
+ (function () {
7842
+ // ensure AMD is not active for the model, so that any UMD exports as commonjs
7843
+ var define = null;
7844
+ var exports = _src_handlers_script_data_DataInliner != null ? _src_handlers_script_data_DataInliner : {};
7845
+ var module = { exports: exports };
7846
+
7847
+ "use strict";
7848
+ Object.defineProperty(exports, "__esModule", { value: true });
7849
+ exports.DataInliner = void 0;
7850
+ const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
7851
+ class DataInliner extends BaseRewriter_1.BaseRewriter {
7852
+ rewriteRoot(resourceInput, resourceOutput) {
7853
+ }
7854
+ rewritePartial(content, ownerResource) {
7855
+ }
7856
+ async rewriteResource(resource) {
7857
+ for (let res of resource.dependencies) {
7858
+ if (/(json|yml)$/.test(res.url) === false) {
7859
+ continue;
7860
+ }
7861
+ if (res.import != null) {
7862
+ await this.rewriteImport(resource, res);
7863
+ continue;
7864
+ }
7865
+ console.error('CJS not implemented');
7866
+ }
7867
+ }
7868
+ accepts(type) {
7869
+ return type === 'js';
7870
+ }
7871
+ rewriteImport(resource, dep) {
7872
+ let rgx = new RegExp(`import\\s+(?<name>[\\w_$]+)\\s+from\\s+['"]${dep.url}['"];?`);
7873
+ let match = rgx.exec(resource.content);
7874
+ if (match == null) {
7875
+ console.error(`No data import found for ${dep.url} in ${resource.filename}`);
7876
+ return;
7877
+ }
7878
+ let name = match.groups.name;
7879
+ let json = dep.resource.content;
7880
+ if (typeof json !== 'string') {
7881
+ json = JSON.stringify(json);
7882
+ }
7883
+ let code = `const ${name} = ${json}`;
7884
+ let content = resource.content.replace(match[0], code);
7885
+ resource.content = content;
7886
+ let i = resource.dependencies.indexOf(dep);
7887
+ resource.dependencies.splice(i, 1);
7888
+ this.solution.outputResources.remove(dep.resource);
7889
+ }
7890
+ }
7891
+ exports.DataInliner = DataInliner;
7892
+ ;
7893
+ //# sourceMappingURL=DataInliner.js.map
7894
+ //# sourceMappingURL=DataInliner.ts.map;
7895
+
7896
+ function __isObj(x) {
7897
+ return x != null && typeof x === 'object' && x.constructor === Object;
7898
+ }
7899
+ if (_src_handlers_script_data_DataInliner === module.exports) {
7900
+ // do nothing if
7901
+ } else if (__isObj(_src_handlers_script_data_DataInliner) && __isObj(module.exports)) {
7902
+ Object.assign(_src_handlers_script_data_DataInliner, module.exports);
7903
+ } else {
7904
+ _src_handlers_script_data_DataInliner = module.exports;
7905
+ }
7906
+
7907
+ ;
7908
+ }());
7909
+
7910
+ // end:source ./ModuleSimplified.js
7911
+
7912
+
7789
7913
  // source ./ModuleSimplified.js
7790
7914
  var _src_handlers_script_ScriptRewriter;
7791
7915
  (function () {
@@ -7799,18 +7923,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
7799
7923
  exports.ScriptRewriter = void 0;
7800
7924
  const IncludeJsHandler_1 = _src_handlers_script_include_js_IncludeJsHandler;
7801
7925
  const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
7926
+ const DataInliner_1 = _src_handlers_script_data_DataInliner;
7802
7927
  class ScriptRewriter extends BaseRewriter_1.BaseRewriter {
7803
7928
  constructor() {
7804
7929
  super(...arguments);
7805
7930
  this.rewriters = [
7806
- new IncludeJsHandler_1.IncludeJsHandler.Rewriter(this.solution, this.handler)
7931
+ new IncludeJsHandler_1.IncludeJsHandler.Rewriter(this.solution, this.handler),
7932
+ new DataInliner_1.DataInliner(this.solution, this.handler),
7807
7933
  ];
7808
7934
  }
7809
7935
  rewritePartial(content, ownerResource) {
7810
7936
  }
7811
7937
  rewriteResource(resource) {
7812
- this.rewriters.forEach(rewriter => {
7813
- rewriter.rewriteResource(resource);
7938
+ return this.rewriters.map(rewriter => {
7939
+ return rewriter.rewriteResource(resource);
7814
7940
  });
7815
7941
  }
7816
7942
  accepts(type) {
@@ -8415,6 +8541,9 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8415
8541
  return;
8416
8542
  }
8417
8543
  if (dep.resource.filename.startsWith(appBase) === false) {
8544
+ // if (path_hasExtension(dep.url) === false) {
8545
+ // rewriteToRelativeUrls[dep.url] = dep.url + '.' + this.solution.opts.outputExtension;
8546
+ // }
8418
8547
  // is project dependency
8419
8548
  return;
8420
8549
  }
@@ -8422,17 +8551,17 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8422
8551
  if (relativePath == null || /(..\/)*?\/?node_modules/.test(relativePath)) {
8423
8552
  return;
8424
8553
  }
8425
- relativePath = (0, path_1.path_changeExtension)(relativePath, null);
8554
+ relativePath = (0, path_1.path_changeExtension)(relativePath, this.solution.opts.outputExtension);
8426
8555
  relativePath = relativePath.startsWith('.')
8427
8556
  ? relativePath
8428
8557
  : './' + relativePath;
8429
8558
  rewriteToRelativeUrls[dep.url] = relativePath;
8430
8559
  })
8431
8560
  .toArray();
8432
- resource.content = rewriteUrls(resource.content, rewriteToRelativeUrls);
8561
+ resource.content = rewriteUrls(resource, rewriteToRelativeUrls);
8433
8562
  }
8434
8563
  let result = [
8435
- createOutputItem(cloneWithExtension(resource, 'js'))
8564
+ createOutputItem(cloneWithExtension(resource, this.solution.opts.outputExtension))
8436
8565
  ];
8437
8566
  let extra = [{
8438
8567
  ext: 'ts.map',
@@ -8444,8 +8573,14 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8444
8573
  let readFile = Configuration_1.Configuration.Instance.get('readFile');
8445
8574
  await (0, alot_1.default)(extra).forEachAsync(async (x) => {
8446
8575
  let cloned = cloneWithExtension(resource, x.ext);
8447
- cloned.content = await readFile(cloned.filename);
8448
- cloned.content = rewriteUrls(cloned.content, rewriteToRelativeUrls);
8576
+ try {
8577
+ cloned.content = await readFile(cloned.filename);
8578
+ }
8579
+ catch (e) {
8580
+ console.error(`Error loading ${resource.filename} from ${parent.resource.filename}`);
8581
+ throw e;
8582
+ }
8583
+ cloned.content = rewriteUrls(cloned, rewriteToRelativeUrls);
8449
8584
  result.push(createOutputItem(cloneWithExtension(cloned, x.output)));
8450
8585
  if (x.ext === 'ts.map' && cloned.content != null) {
8451
8586
  let outputItem = result[result.length - 1];
@@ -8472,9 +8607,16 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
8472
8607
  cloned.url = (0, path_1.path_changeExtension)(cloned.url, ext);
8473
8608
  return cloned;
8474
8609
  }
8475
- function rewriteUrls(content, rewriteToRelativeUrls) {
8610
+ function rewriteUrls(resource, rewriteToRelativeUrls) {
8611
+ let content = resource.content;
8612
+ if (content == null) {
8613
+ console.error(`<rewrite urls> No content for ${resource.filename}`);
8614
+ return '';
8615
+ }
8476
8616
  for (let key in rewriteToRelativeUrls) {
8477
- content = content.replaceAll(key, rewriteToRelativeUrls[key]);
8617
+ content = content
8618
+ .replaceAll(`"${key}"`, `"${rewriteToRelativeUrls[key]}"`)
8619
+ .replaceAll(`'${key}'`, `'${rewriteToRelativeUrls[key]}'`);
8478
8620
  }
8479
8621
  return content;
8480
8622
  }
@@ -11437,7 +11579,13 @@ function getDependenciesExternal(deps, resource, solution) {
11437
11579
  .then(() => deps);
11438
11580
  }
11439
11581
  function filterDynamicDeps(info, solution) {
11440
- info.dependencies = info.dependencies.filter(dep => isDynamicDependency(dep, solution) === false);
11582
+ info.dependencies = info.dependencies.filter(dep => {
11583
+ let isDynamic = isDynamicDependency(dep, solution);
11584
+ if (isDynamic) {
11585
+ solution.outputResources.addDynamicDependency(dep);
11586
+ }
11587
+ return isDynamic === false;
11588
+ });
11441
11589
  return info;
11442
11590
  }
11443
11591
  function isDynamicDependency(dep, solution) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-bundler",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "",
5
5
  "main": "lib/bundler.js",
6
6
  "bin": {