app-bundler 0.1.10 → 0.1.11

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 +207 -185
  2. package/lib/cli.js +207 -185
  3. package/package.json +1 -1
package/lib/bundler.js CHANGED
@@ -4610,202 +4610,218 @@ var __register, __require, require;
4610
4610
 
4611
4611
  (function(){
4612
4612
 
4613
- // source ./path.js
4614
- var path_getDir,
4615
- path_resolveCurrent,
4616
- path_normalize,
4617
- path_resolveUrl,
4618
- path_combine
4619
- ;
4620
- (function(){
4621
- var isNodeJS = typeof process !== 'undefined'
4622
- && typeof window === 'undefined'
4623
- && typeof navigator === 'undefined';
4624
-
4625
- path_getDir = function(path) {
4626
- return path.substring(0, path.lastIndexOf('/') + 1);
4627
- };
4628
-
4629
- (function(){
4630
- var current_;
4631
- if (isNodeJS === false) {
4632
- path_resolveCurrent = function(){
4633
- if (current_ != null) return current_;
4634
-
4635
- var fn = 'baseURI' in window.document
4636
- ? fromBase
4637
- : fromLocation;
4638
- return (current_ = path_sliceFilename(fn()));
4639
- };
4640
- function fromBase() {
4641
- var path = window.document.baseURI;
4642
- var i = path.indexOf('?');
4643
- return i === -1 ? path : path.substring(0, i);
4644
- }
4645
- function fromLocation() {
4646
- return window.location.origin + window.location.pathname;
4647
- }
4648
- }
4649
- else {
4650
-
4651
- path_resolveCurrent = function(){
4652
- if (current_ != null) return current_;
4653
- return (current_ = path_win32Normalize(__dirname));
4654
- };
4655
- }
4656
- }());
4657
-
4658
-
4659
- path_normalize = function(path) {
4660
- var path_ = path
4661
- .replace(new RegExp("\\\\\\\\", "g"), '/')
4662
- // remove double slashes, but not near protocol
4663
- .replace(new RegExp("([^:\\\\/])\\\\/{2,}", "g"), '$1/')
4664
- // './xx' to relative string
4665
- .replace(new RegExp("^\\\\.\\\\/"), '')
4666
- // join 'xx/./xx'
4667
- .replace(new RegExp("\\\\/\\\\.\\\\//", "g"), '/')
4668
- ;
4669
- path_ = path_collapse(path_);
4670
- return path_;
4671
- };
4672
- path_resolveUrl = function(path, location) {
4673
- if (/\\.\\w+$/.test(path) === false) {
4674
- path += '.js';
4675
- }
4676
- var url = path_normalize(path);
4677
- if (url[0] === '/') {
4678
- url = path_combine(path_resolveCurrent(), url);
4679
- } else if (rgx_PROTOCOL.test(url) === false) {
4680
- url = path_normalize(path_combine(location || path_resolveCurrent(), url));
4681
- }
4682
- if (rgx_PROTOCOL.test(url) === false) {
4683
- url = 'file://' + url;
4684
- }
4685
- return url;
4686
- };
4687
-
4688
- path_combine = function() {
4689
- var out = '',
4690
- imax = arguments.length,
4691
- i = -1, x;
4692
- while ( ++i < imax ){
4693
- x = arguments[i];
4694
- if (!x) continue;
4695
-
4696
- x = path_normalize(x);
4697
- if (out === '') {
4698
- out = x;
4699
- continue;
4700
- }
4701
- if (out[out.length - 1] !== '/') {
4702
- out += '/'
4703
- }
4704
- if (x[0] === '/') {
4705
- x = x.substring(1);
4706
- }
4707
- out += x;
4708
- }
4709
- return path_collapse(out);
4710
- };
4711
-
4712
- var rgx_PROTOCOL = /^(file|https?):/i,
4713
- rgx_SUB_DIR = new RegExp("[^\\\\/\\\\.]+\/\\\\.\\\\.\\\\/"),
4714
- rgx_FILENAME = new RegExp("\\\\/[^\\\\/]+\\\\.\\\\w+(\\\\?.*)?(#.*)?$"),
4715
- rgx_EXT = new RegExp("\\\\.(\\\\w+)$"),
4716
- rgx_win32Drive = new RegExp("(^\\\\/?\\\\w{1}:)(\\\\/|$)")
4717
- ;
4718
-
4719
- function path_win32Normalize (path){
4720
- path = path_normalize(path);
4721
- if (path.substring(0, 5) === 'file:')
4722
- return path;
4723
-
4724
- return 'file://' + path;
4725
- }
4726
-
4727
- function path_collapse(url_) {
4728
- var url = url_;
4729
- while (rgx_SUB_DIR.test(url)) {
4730
- url = url.replace(rgx_SUB_DIR, '');
4731
- }
4732
- return url;
4733
- }
4734
- function path_ensureTrailingSlash(path) {
4735
- if (path.charCodeAt(path.length - 1) === 47 /* / */)
4736
- return path;
4737
-
4738
- return path + '/';
4739
- }
4740
- function path_sliceFilename(path) {
4741
- return path_ensureTrailingSlash(path.replace(rgx_FILENAME, ''));
4742
- }
4743
-
4744
- }());
4745
-
4746
- // end:source ./path.js
4613
+ // source ./path.js
4614
+ var path_getDir,
4615
+ path_resolveCurrent,
4616
+ path_normalize,
4617
+ path_resolveUrl,
4618
+ path_combine
4619
+ ;
4620
+ (function(){
4621
+ var isNodeJS = typeof process !== 'undefined'
4622
+ && typeof window === 'undefined'
4623
+ && typeof navigator === 'undefined';
4624
+
4625
+ path_getDir = function(path) {
4626
+ return path.substring(0, path.lastIndexOf('/') + 1);
4627
+ };
4628
+
4629
+ (function(){
4630
+ var current_;
4631
+ if (isNodeJS === false) {
4632
+ path_resolveCurrent = function(){
4633
+ if (current_ != null) return current_;
4634
+
4635
+ var fn = 'baseURI' in window.document
4636
+ ? fromBase
4637
+ : fromLocation;
4638
+ return (current_ = path_sliceFilename(fn()));
4639
+ };
4640
+ function fromBase() {
4641
+ var path = window.document.baseURI;
4642
+ var i = path.indexOf('?');
4643
+ return i === -1 ? path : path.substring(0, i);
4644
+ }
4645
+ function fromLocation() {
4646
+ return window.location.origin + window.location.pathname;
4647
+ }
4648
+ }
4649
+ else {
4650
+
4651
+ path_resolveCurrent = function(){
4652
+ if (current_ != null) return current_;
4653
+ return (current_ = path_win32Normalize(__dirname));
4654
+ };
4655
+ }
4656
+ }());
4657
+
4658
+
4659
+ path_normalize = function(path) {
4660
+ var path_ = path
4661
+ .replace(new RegExp("\\\\\\\\", "g"), '/')
4662
+ // remove double slashes, but not near protocol
4663
+ .replace(new RegExp("([^:\\\\/])\\\\/{2,}", "g"), '$1/')
4664
+ // './xx' to relative string
4665
+ .replace(new RegExp("^\\\\.\\\\/"), '')
4666
+ // join 'xx/./xx'
4667
+ .replace(new RegExp("\\\\/\\\\.\\\\//", "g"), '/')
4668
+ ;
4669
+ path_ = path_collapse(path_);
4670
+ return path_;
4671
+ };
4672
+ path_resolveUrl = function(path, location) {
4673
+ if (/\\.\\w+$/.test(path) === false) {
4674
+ path += '.js';
4675
+ }
4676
+ var url = path_normalize(path);
4677
+ if (url[0] === '/') {
4678
+ url = path_combine(path_resolveCurrent(), url);
4679
+ } else if (rgx_PROTOCOL.test(url) === false) {
4680
+ url = path_normalize(path_combine(location || path_resolveCurrent(), url));
4681
+ }
4682
+ if (rgx_PROTOCOL.test(url) === false) {
4683
+ url = 'file://' + url;
4684
+ }
4685
+ return url;
4686
+ };
4687
+
4688
+ path_combine = function() {
4689
+ var out = '',
4690
+ imax = arguments.length,
4691
+ i = -1, x;
4692
+ while ( ++i < imax ){
4693
+ x = arguments[i];
4694
+ if (!x) continue;
4695
+
4696
+ x = path_normalize(x);
4697
+ if (out === '') {
4698
+ out = x;
4699
+ continue;
4700
+ }
4701
+ if (out[out.length - 1] !== '/') {
4702
+ out += '/'
4703
+ }
4704
+ if (x[0] === '/') {
4705
+ x = x.substring(1);
4706
+ }
4707
+ out += x;
4708
+ }
4709
+ return path_collapse(out);
4710
+ };
4711
+
4712
+ var rgx_PROTOCOL = /^(file|https?):/i,
4713
+ rgx_SUB_DIR = new RegExp("[^\\\\/\\\\.]+\/\\\\.\\\\.\\\\/"),
4714
+ rgx_FILENAME = new RegExp("\\\\/[^\\\\/]+\\\\.\\\\w+(\\\\?.*)?(#.*)?$"),
4715
+ rgx_EXT = new RegExp("\\\\.(\\\\w+)$"),
4716
+ rgx_win32Drive = new RegExp("(^\\\\/?\\\\w{1}:)(\\\\/|$)")
4717
+ ;
4718
+
4719
+ function path_win32Normalize (path){
4720
+ path = path_normalize(path);
4721
+ if (path.substring(0, 5) === 'file:')
4722
+ return path;
4723
+
4724
+ return 'file://' + path;
4725
+ }
4726
+
4727
+ function path_collapse(url_) {
4728
+ var url = url_;
4729
+ while (rgx_SUB_DIR.test(url)) {
4730
+ url = url.replace(rgx_SUB_DIR, '');
4731
+ }
4732
+ return url;
4733
+ }
4734
+ function path_ensureTrailingSlash(path) {
4735
+ if (path.charCodeAt(path.length - 1) === 47 /* / */)
4736
+ return path;
4737
+
4738
+ return path + '/';
4739
+ }
4740
+ function path_sliceFilename(path) {
4741
+ return path_ensureTrailingSlash(path.replace(rgx_FILENAME, ''));
4742
+ }
4743
+
4744
+ }());
4745
+
4746
+ // end:source ./path.js
4747
+
4748
+ var __global = typeof global !== 'undefined' && global ? global : window;
4749
+ var __nativeRequire = __global.require || require;
4750
+ var __originalRequire = function (path_) {
4751
+ var location = this.location;
4752
+ var path = path_resolveUrl(path_, location);
4747
4753
 
4748
- var __global = typeof global !== 'undefined' && global ? global : window;
4749
- var __nativeRequire = __global.require;
4750
- var __originalRequire = function (path_) {
4751
- var location = this.location;
4752
- var path = path_resolveUrl(path_, location);
4754
+ if (modules[path]) {
4755
+ return modules[path].runOnce();
4756
+ }
4757
+ var pathWithoutExt = path.replace(/\.\w+$/, '').toLowerCase();
4758
+ for (var key in modules) {
4759
+ var $pathWithoutExt = key.replace(/\.\w+$/, '').toLowerCase();
4760
+ if ($pathWithoutExt === pathWithoutExt) {
4761
+ let module = modules[path] = modules[key];
4762
+ return module.runOnce();
4763
+ }
4764
+ }
4753
4765
 
4754
- if (modules[path]) {
4755
- return modules[path].runOnce();
4756
- }
4766
+ return __nativeRequire(path_);
4767
+ };
4757
4768
 
4758
- return __nativeRequire(path_);
4759
- };
4769
+ __register = function (path, factory) {
4770
+ var filename = path_resolveUrl(path);
4771
+ modules[filename] = new Module(filename, factory);
4772
+ };
4760
4773
 
4761
- __register = function (path, factory) {
4762
- var filename = path_resolveUrl(path);
4763
- modules[filename] = new Module(filename, factory);
4764
- };
4774
+ __require =__originalRequire.bind({ location: path_getDir(path_resolveUrl('%ROOT_DIR%')) });
4765
4775
 
4766
- __require =__originalRequire.bind({ location: path_getDir(path_resolveUrl('%ROOT_DIR%')) });
4776
+ var modules = {};
4777
+ var Module = function(filename, factory){
4778
+ this.filename = filename;
4779
+ this.dirname = path_getDir(filename);
4780
+ this.factory = factory;
4781
+ this.exports = null;
4782
+ };
4783
+ Module.prototype.runOnce = function(){
4784
+ if (this.exports != null) {
4785
+ return this.exports;
4786
+ }
4787
+ var require = __originalRequire.bind({
4788
+ location: this.dirname
4789
+ });
4790
+ this.exports = {};
4791
+ this.factory(
4792
+ require,
4793
+ this,
4794
+ this.exports,
4795
+ this.filename,
4796
+ this.dirname
4797
+ );
4798
+ return this.exports;
4799
+ };
4767
4800
 
4768
- var modules = {};
4769
- var Module = function(filename, factory){
4770
- this.filename = filename;
4771
- this.dirname = path_getDir(filename);
4772
- this.factory = factory;
4773
- this.exports = null;
4774
- };
4775
- Module.prototype.runOnce = function(){
4776
- if (this.exports != null) {
4777
- return this.exports;
4778
- }
4779
- var require = __originalRequire.bind({
4780
- location: this.dirname
4781
- });
4782
- this.exports = {};
4783
- this.factory(
4784
- require,
4785
- this,
4786
- this.exports,
4787
- this.filename,
4788
- this.dirname
4789
- );
4790
- return this.exports;
4791
- };
4792
-
4793
- require = __require;
4801
+ require = __require;
4794
4802
 
4795
- if (__nativeRequire == null) {
4796
- __global.require = __require;
4797
- }
4803
+ if (__nativeRequire == null) {
4804
+ __global.require = __require;
4805
+ }
4798
4806
  }());
4807
+
4799
4808
  // end:source ./Header.js
4800
4809
  `,
4801
4810
  RootModule: `
4802
4811
  // source ./RootModule.js
4812
+ %BUNDLE%
4813
+
4814
+ // end:source ./RootModule.js
4815
+ `,
4816
+ RootModuleWrapped: `
4817
+ // source ./RootModuleWrapped.js
4803
4818
  (function(){
4804
-
4805
- %BUNDLE%
4819
+
4820
+ %BUNDLE%
4806
4821
 
4807
4822
  }());
4808
- // end:source ./RootModule.js
4823
+
4824
+ // end:source ./RootModuleWrapped.js
4809
4825
  `,
4810
4826
  UMD: `
4811
4827
  // source ./UMD.js
@@ -5098,6 +5114,9 @@ class ModuleWrapper {
5098
5114
  wrap(body) {
5099
5115
  var wrapper = this.solution.opts.package.moduleWrapper;
5100
5116
  switch (wrapper) {
5117
+ case 'script':
5118
+ body = this.wrapSimple(body);
5119
+ break;
5101
5120
  case 'iif':
5102
5121
  body = this.wrapWithIIF(body);
5103
5122
  break;
@@ -5107,18 +5126,21 @@ class ModuleWrapper {
5107
5126
  case 'custom':
5108
5127
  body = this.wrapWithCustom(body);
5109
5128
  break;
5110
- case 'script':
5111
- break;
5112
5129
  default:
5113
5130
  throw new Error('Uknown module wrapper: ' + wrapper);
5114
5131
  }
5115
5132
  return body;
5116
5133
  }
5117
- wrapWithIIF(body) {
5134
+ wrapSimple(body) {
5118
5135
  return Templates_1.Templates
5119
5136
  .RootModule
5120
5137
  .replace('%BUNDLE%', () => body);
5121
5138
  }
5139
+ wrapWithIIF(body) {
5140
+ return Templates_1.Templates
5141
+ .RootModuleWrapped
5142
+ .replace('%BUNDLE%', () => body);
5143
+ }
5122
5144
  wrapWithUMD(body) {
5123
5145
  var opts = this.solution.opts.package;
5124
5146
  var name = opts.moduleName || '';
@@ -6108,7 +6130,7 @@ class IncludeJsHandler extends BaseHandler_1.BaseHandler {
6108
6130
  constructor(solution) {
6109
6131
  super(solution);
6110
6132
  // if (this.solution.opts.package.module === 'includejs') {
6111
- // this.registerMappings_();
6133
+ // this.registerMappings_();
6112
6134
  // }
6113
6135
  }
6114
6136
  accepts(resource) {
package/lib/cli.js CHANGED
@@ -4612,202 +4612,218 @@ var __register, __require, require;
4612
4612
 
4613
4613
  (function(){
4614
4614
 
4615
- // source ./path.js
4616
- var path_getDir,
4617
- path_resolveCurrent,
4618
- path_normalize,
4619
- path_resolveUrl,
4620
- path_combine
4621
- ;
4622
- (function(){
4623
- var isNodeJS = typeof process !== 'undefined'
4624
- && typeof window === 'undefined'
4625
- && typeof navigator === 'undefined';
4626
-
4627
- path_getDir = function(path) {
4628
- return path.substring(0, path.lastIndexOf('/') + 1);
4629
- };
4630
-
4631
- (function(){
4632
- var current_;
4633
- if (isNodeJS === false) {
4634
- path_resolveCurrent = function(){
4635
- if (current_ != null) return current_;
4636
-
4637
- var fn = 'baseURI' in window.document
4638
- ? fromBase
4639
- : fromLocation;
4640
- return (current_ = path_sliceFilename(fn()));
4641
- };
4642
- function fromBase() {
4643
- var path = window.document.baseURI;
4644
- var i = path.indexOf('?');
4645
- return i === -1 ? path : path.substring(0, i);
4646
- }
4647
- function fromLocation() {
4648
- return window.location.origin + window.location.pathname;
4649
- }
4650
- }
4651
- else {
4652
-
4653
- path_resolveCurrent = function(){
4654
- if (current_ != null) return current_;
4655
- return (current_ = path_win32Normalize(__dirname));
4656
- };
4657
- }
4658
- }());
4659
-
4660
-
4661
- path_normalize = function(path) {
4662
- var path_ = path
4663
- .replace(new RegExp("\\\\\\\\", "g"), '/')
4664
- // remove double slashes, but not near protocol
4665
- .replace(new RegExp("([^:\\\\/])\\\\/{2,}", "g"), '$1/')
4666
- // './xx' to relative string
4667
- .replace(new RegExp("^\\\\.\\\\/"), '')
4668
- // join 'xx/./xx'
4669
- .replace(new RegExp("\\\\/\\\\.\\\\//", "g"), '/')
4670
- ;
4671
- path_ = path_collapse(path_);
4672
- return path_;
4673
- };
4674
- path_resolveUrl = function(path, location) {
4675
- if (/\\.\\w+$/.test(path) === false) {
4676
- path += '.js';
4677
- }
4678
- var url = path_normalize(path);
4679
- if (url[0] === '/') {
4680
- url = path_combine(path_resolveCurrent(), url);
4681
- } else if (rgx_PROTOCOL.test(url) === false) {
4682
- url = path_normalize(path_combine(location || path_resolveCurrent(), url));
4683
- }
4684
- if (rgx_PROTOCOL.test(url) === false) {
4685
- url = 'file://' + url;
4686
- }
4687
- return url;
4688
- };
4689
-
4690
- path_combine = function() {
4691
- var out = '',
4692
- imax = arguments.length,
4693
- i = -1, x;
4694
- while ( ++i < imax ){
4695
- x = arguments[i];
4696
- if (!x) continue;
4697
-
4698
- x = path_normalize(x);
4699
- if (out === '') {
4700
- out = x;
4701
- continue;
4702
- }
4703
- if (out[out.length - 1] !== '/') {
4704
- out += '/'
4705
- }
4706
- if (x[0] === '/') {
4707
- x = x.substring(1);
4708
- }
4709
- out += x;
4710
- }
4711
- return path_collapse(out);
4712
- };
4713
-
4714
- var rgx_PROTOCOL = /^(file|https?):/i,
4715
- rgx_SUB_DIR = new RegExp("[^\\\\/\\\\.]+\/\\\\.\\\\.\\\\/"),
4716
- rgx_FILENAME = new RegExp("\\\\/[^\\\\/]+\\\\.\\\\w+(\\\\?.*)?(#.*)?$"),
4717
- rgx_EXT = new RegExp("\\\\.(\\\\w+)$"),
4718
- rgx_win32Drive = new RegExp("(^\\\\/?\\\\w{1}:)(\\\\/|$)")
4719
- ;
4720
-
4721
- function path_win32Normalize (path){
4722
- path = path_normalize(path);
4723
- if (path.substring(0, 5) === 'file:')
4724
- return path;
4725
-
4726
- return 'file://' + path;
4727
- }
4728
-
4729
- function path_collapse(url_) {
4730
- var url = url_;
4731
- while (rgx_SUB_DIR.test(url)) {
4732
- url = url.replace(rgx_SUB_DIR, '');
4733
- }
4734
- return url;
4735
- }
4736
- function path_ensureTrailingSlash(path) {
4737
- if (path.charCodeAt(path.length - 1) === 47 /* / */)
4738
- return path;
4739
-
4740
- return path + '/';
4741
- }
4742
- function path_sliceFilename(path) {
4743
- return path_ensureTrailingSlash(path.replace(rgx_FILENAME, ''));
4744
- }
4745
-
4746
- }());
4747
-
4748
- // end:source ./path.js
4615
+ // source ./path.js
4616
+ var path_getDir,
4617
+ path_resolveCurrent,
4618
+ path_normalize,
4619
+ path_resolveUrl,
4620
+ path_combine
4621
+ ;
4622
+ (function(){
4623
+ var isNodeJS = typeof process !== 'undefined'
4624
+ && typeof window === 'undefined'
4625
+ && typeof navigator === 'undefined';
4626
+
4627
+ path_getDir = function(path) {
4628
+ return path.substring(0, path.lastIndexOf('/') + 1);
4629
+ };
4630
+
4631
+ (function(){
4632
+ var current_;
4633
+ if (isNodeJS === false) {
4634
+ path_resolveCurrent = function(){
4635
+ if (current_ != null) return current_;
4636
+
4637
+ var fn = 'baseURI' in window.document
4638
+ ? fromBase
4639
+ : fromLocation;
4640
+ return (current_ = path_sliceFilename(fn()));
4641
+ };
4642
+ function fromBase() {
4643
+ var path = window.document.baseURI;
4644
+ var i = path.indexOf('?');
4645
+ return i === -1 ? path : path.substring(0, i);
4646
+ }
4647
+ function fromLocation() {
4648
+ return window.location.origin + window.location.pathname;
4649
+ }
4650
+ }
4651
+ else {
4652
+
4653
+ path_resolveCurrent = function(){
4654
+ if (current_ != null) return current_;
4655
+ return (current_ = path_win32Normalize(__dirname));
4656
+ };
4657
+ }
4658
+ }());
4659
+
4660
+
4661
+ path_normalize = function(path) {
4662
+ var path_ = path
4663
+ .replace(new RegExp("\\\\\\\\", "g"), '/')
4664
+ // remove double slashes, but not near protocol
4665
+ .replace(new RegExp("([^:\\\\/])\\\\/{2,}", "g"), '$1/')
4666
+ // './xx' to relative string
4667
+ .replace(new RegExp("^\\\\.\\\\/"), '')
4668
+ // join 'xx/./xx'
4669
+ .replace(new RegExp("\\\\/\\\\.\\\\//", "g"), '/')
4670
+ ;
4671
+ path_ = path_collapse(path_);
4672
+ return path_;
4673
+ };
4674
+ path_resolveUrl = function(path, location) {
4675
+ if (/\\.\\w+$/.test(path) === false) {
4676
+ path += '.js';
4677
+ }
4678
+ var url = path_normalize(path);
4679
+ if (url[0] === '/') {
4680
+ url = path_combine(path_resolveCurrent(), url);
4681
+ } else if (rgx_PROTOCOL.test(url) === false) {
4682
+ url = path_normalize(path_combine(location || path_resolveCurrent(), url));
4683
+ }
4684
+ if (rgx_PROTOCOL.test(url) === false) {
4685
+ url = 'file://' + url;
4686
+ }
4687
+ return url;
4688
+ };
4689
+
4690
+ path_combine = function() {
4691
+ var out = '',
4692
+ imax = arguments.length,
4693
+ i = -1, x;
4694
+ while ( ++i < imax ){
4695
+ x = arguments[i];
4696
+ if (!x) continue;
4697
+
4698
+ x = path_normalize(x);
4699
+ if (out === '') {
4700
+ out = x;
4701
+ continue;
4702
+ }
4703
+ if (out[out.length - 1] !== '/') {
4704
+ out += '/'
4705
+ }
4706
+ if (x[0] === '/') {
4707
+ x = x.substring(1);
4708
+ }
4709
+ out += x;
4710
+ }
4711
+ return path_collapse(out);
4712
+ };
4713
+
4714
+ var rgx_PROTOCOL = /^(file|https?):/i,
4715
+ rgx_SUB_DIR = new RegExp("[^\\\\/\\\\.]+\/\\\\.\\\\.\\\\/"),
4716
+ rgx_FILENAME = new RegExp("\\\\/[^\\\\/]+\\\\.\\\\w+(\\\\?.*)?(#.*)?$"),
4717
+ rgx_EXT = new RegExp("\\\\.(\\\\w+)$"),
4718
+ rgx_win32Drive = new RegExp("(^\\\\/?\\\\w{1}:)(\\\\/|$)")
4719
+ ;
4720
+
4721
+ function path_win32Normalize (path){
4722
+ path = path_normalize(path);
4723
+ if (path.substring(0, 5) === 'file:')
4724
+ return path;
4725
+
4726
+ return 'file://' + path;
4727
+ }
4728
+
4729
+ function path_collapse(url_) {
4730
+ var url = url_;
4731
+ while (rgx_SUB_DIR.test(url)) {
4732
+ url = url.replace(rgx_SUB_DIR, '');
4733
+ }
4734
+ return url;
4735
+ }
4736
+ function path_ensureTrailingSlash(path) {
4737
+ if (path.charCodeAt(path.length - 1) === 47 /* / */)
4738
+ return path;
4739
+
4740
+ return path + '/';
4741
+ }
4742
+ function path_sliceFilename(path) {
4743
+ return path_ensureTrailingSlash(path.replace(rgx_FILENAME, ''));
4744
+ }
4745
+
4746
+ }());
4747
+
4748
+ // end:source ./path.js
4749
+
4750
+ var __global = typeof global !== 'undefined' && global ? global : window;
4751
+ var __nativeRequire = __global.require || require;
4752
+ var __originalRequire = function (path_) {
4753
+ var location = this.location;
4754
+ var path = path_resolveUrl(path_, location);
4749
4755
 
4750
- var __global = typeof global !== 'undefined' && global ? global : window;
4751
- var __nativeRequire = __global.require;
4752
- var __originalRequire = function (path_) {
4753
- var location = this.location;
4754
- var path = path_resolveUrl(path_, location);
4756
+ if (modules[path]) {
4757
+ return modules[path].runOnce();
4758
+ }
4759
+ var pathWithoutExt = path.replace(/\.\w+$/, '').toLowerCase();
4760
+ for (var key in modules) {
4761
+ var $pathWithoutExt = key.replace(/\.\w+$/, '').toLowerCase();
4762
+ if ($pathWithoutExt === pathWithoutExt) {
4763
+ let module = modules[path] = modules[key];
4764
+ return module.runOnce();
4765
+ }
4766
+ }
4755
4767
 
4756
- if (modules[path]) {
4757
- return modules[path].runOnce();
4758
- }
4768
+ return __nativeRequire(path_);
4769
+ };
4759
4770
 
4760
- return __nativeRequire(path_);
4761
- };
4771
+ __register = function (path, factory) {
4772
+ var filename = path_resolveUrl(path);
4773
+ modules[filename] = new Module(filename, factory);
4774
+ };
4762
4775
 
4763
- __register = function (path, factory) {
4764
- var filename = path_resolveUrl(path);
4765
- modules[filename] = new Module(filename, factory);
4766
- };
4776
+ __require =__originalRequire.bind({ location: path_getDir(path_resolveUrl('%ROOT_DIR%')) });
4767
4777
 
4768
- __require =__originalRequire.bind({ location: path_getDir(path_resolveUrl('%ROOT_DIR%')) });
4778
+ var modules = {};
4779
+ var Module = function(filename, factory){
4780
+ this.filename = filename;
4781
+ this.dirname = path_getDir(filename);
4782
+ this.factory = factory;
4783
+ this.exports = null;
4784
+ };
4785
+ Module.prototype.runOnce = function(){
4786
+ if (this.exports != null) {
4787
+ return this.exports;
4788
+ }
4789
+ var require = __originalRequire.bind({
4790
+ location: this.dirname
4791
+ });
4792
+ this.exports = {};
4793
+ this.factory(
4794
+ require,
4795
+ this,
4796
+ this.exports,
4797
+ this.filename,
4798
+ this.dirname
4799
+ );
4800
+ return this.exports;
4801
+ };
4769
4802
 
4770
- var modules = {};
4771
- var Module = function(filename, factory){
4772
- this.filename = filename;
4773
- this.dirname = path_getDir(filename);
4774
- this.factory = factory;
4775
- this.exports = null;
4776
- };
4777
- Module.prototype.runOnce = function(){
4778
- if (this.exports != null) {
4779
- return this.exports;
4780
- }
4781
- var require = __originalRequire.bind({
4782
- location: this.dirname
4783
- });
4784
- this.exports = {};
4785
- this.factory(
4786
- require,
4787
- this,
4788
- this.exports,
4789
- this.filename,
4790
- this.dirname
4791
- );
4792
- return this.exports;
4793
- };
4794
-
4795
- require = __require;
4803
+ require = __require;
4796
4804
 
4797
- if (__nativeRequire == null) {
4798
- __global.require = __require;
4799
- }
4805
+ if (__nativeRequire == null) {
4806
+ __global.require = __require;
4807
+ }
4800
4808
  }());
4809
+
4801
4810
  // end:source ./Header.js
4802
4811
  `,
4803
4812
  RootModule: `
4804
4813
  // source ./RootModule.js
4814
+ %BUNDLE%
4815
+
4816
+ // end:source ./RootModule.js
4817
+ `,
4818
+ RootModuleWrapped: `
4819
+ // source ./RootModuleWrapped.js
4805
4820
  (function(){
4806
-
4807
- %BUNDLE%
4821
+
4822
+ %BUNDLE%
4808
4823
 
4809
4824
  }());
4810
- // end:source ./RootModule.js
4825
+
4826
+ // end:source ./RootModuleWrapped.js
4811
4827
  `,
4812
4828
  UMD: `
4813
4829
  // source ./UMD.js
@@ -5100,6 +5116,9 @@ class ModuleWrapper {
5100
5116
  wrap(body) {
5101
5117
  var wrapper = this.solution.opts.package.moduleWrapper;
5102
5118
  switch (wrapper) {
5119
+ case 'script':
5120
+ body = this.wrapSimple(body);
5121
+ break;
5103
5122
  case 'iif':
5104
5123
  body = this.wrapWithIIF(body);
5105
5124
  break;
@@ -5109,18 +5128,21 @@ class ModuleWrapper {
5109
5128
  case 'custom':
5110
5129
  body = this.wrapWithCustom(body);
5111
5130
  break;
5112
- case 'script':
5113
- break;
5114
5131
  default:
5115
5132
  throw new Error('Uknown module wrapper: ' + wrapper);
5116
5133
  }
5117
5134
  return body;
5118
5135
  }
5119
- wrapWithIIF(body) {
5136
+ wrapSimple(body) {
5120
5137
  return Templates_1.Templates
5121
5138
  .RootModule
5122
5139
  .replace('%BUNDLE%', () => body);
5123
5140
  }
5141
+ wrapWithIIF(body) {
5142
+ return Templates_1.Templates
5143
+ .RootModuleWrapped
5144
+ .replace('%BUNDLE%', () => body);
5145
+ }
5124
5146
  wrapWithUMD(body) {
5125
5147
  var opts = this.solution.opts.package;
5126
5148
  var name = opts.moduleName || '';
@@ -6110,7 +6132,7 @@ class IncludeJsHandler extends BaseHandler_1.BaseHandler {
6110
6132
  constructor(solution) {
6111
6133
  super(solution);
6112
6134
  // if (this.solution.opts.package.module === 'includejs') {
6113
- // this.registerMappings_();
6135
+ // this.registerMappings_();
6114
6136
  // }
6115
6137
  }
6116
6138
  accepts(resource) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-bundler",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "",
5
5
  "main": "lib/bundler.js",
6
6
  "bin": {