js-build-tools 5.1.1 → 5.2.0

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
@@ -408,277 +408,276 @@ Run any of the above commands with `gulp` or `npm run`.
408
408
 
409
409
  # Available functions documentation
410
410
 
411
- ## Modules
412
-
413
- <dl>
414
- <dt><a href="#module_js-build-tools">js-build-tools</a></dt>
415
- <dd><p>Export these functions to your own project to customize your build pipeline.</p>
416
- </dd>
417
- <dt><a href="#module_gulpConfig">gulpConfig</a></dt>
418
- <dd><p>Modify these configurations to match your project specifications.</p>
419
- </dd>
420
- </dl>
421
-
422
- <a name="module_js-build-tools"></a>
423
-
424
- ## js-build-tools
425
- Export these functions to your own project to customize your build pipeline.
426
-
427
- **Version**: 3.0.0
428
- **Author**: Joshua Heagle <joshuaheagle@gmail.com>
429
- <a name="module_js-build-tools.build"></a>
430
-
431
- ### js-build-tools.build() ⇒ <code>stream.Stream</code>
432
- Runs several processes to build and validate the project.
433
- Cleans, distributes (lint and minify), bundles (lint and minify), creates the readme, then runs the tests.
434
-
435
- **Kind**: static method of [<code>js-build-tools</code>](#module_js-build-tools)
436
- <a name="module_gulpConfig"></a>
437
-
438
- ## gulpConfig
439
- Modify these configurations to match your project specifications.
440
-
441
- **Version**: 3.0.0
442
- **Author**: Joshua Heagle <joshuaheagle@gmail.com>
443
-
444
- * [gulpConfig](#module_gulpConfig)
445
- * _static_
446
- * [.get(path, defaultValue)](#module_gulpConfig.get) ⇒ <code>\*</code> \| <code>null</code>
447
- * [.set(path, value)](#module_gulpConfig.set) ⇒ <code>\*</code>
448
- * _inner_
449
- * [~ArrayableSetting](#module_gulpConfig..ArrayableSetting) : <code>Array.&lt;string&gt;</code> \| <code>string</code>
450
- * [~BooleanSetting](#module_gulpConfig..BooleanSetting) : <code>boolean</code>
451
- * [~FlagStringSetting](#module_gulpConfig..FlagStringSetting) : <code>false</code> \| <code>StringSetting</code>
452
- * [~FlagsSetting](#module_gulpConfig..FlagsSetting) : <code>Object.&lt;string, BooleanSetting&gt;</code>
453
- * [~JestTestFlags](#module_gulpConfig..JestTestFlags) : <code>FlagsSetting</code>
454
- * [~StringSetting](#module_gulpConfig..StringSetting) : <code>string</code>
455
- * [~Setting](#module_gulpConfig..Setting) : <code>ArrayableSetting</code> \| <code>BooleanSetting</code> \| <code>FlagsSetting</code> \| <code>StringSetting</code>
456
- * [~BrowserConfig](#module_gulpConfig..BrowserConfig) : <code>Object.&lt;string, Setting&gt;</code>
457
- * [~DistConfig](#module_gulpConfig..DistConfig) : <code>Object.&lt;string, Setting&gt;</code>
458
- * [~FontConfig](#module_gulpConfig..FontConfig) : <code>Object.&lt;string, Setting&gt;</code>
459
- * [~ImageConfig](#module_gulpConfig..ImageConfig) : <code>Object.&lt;string, Setting&gt;</code>
460
- * [~ReadmeConfig](#module_gulpConfig..ReadmeConfig) : <code>Object.&lt;string, Setting&gt;</code>
461
- * [~SassConfig](#module_gulpConfig..SassConfig) : <code>Object.&lt;string, Setting&gt;</code>
462
- * [~TestConfig](#module_gulpConfig..TestConfig) : <code>Object.&lt;string, Setting&gt;</code>
463
- * [~TsConfig](#module_gulpConfig..TsConfig) : <code>Object.&lt;string, Setting&gt;</code>
464
- * [~Configurations](#module_gulpConfig..Configurations) : <code>Object.&lt;string, Setting&gt;</code>
465
-
466
- <a name="module_gulpConfig.get"></a>
467
-
468
- ### gulpConfig.get(path, defaultValue) ⇒ <code>\*</code> \| <code>null</code>
469
- Retrieve a value from the configurations, default may be returned.
470
-
471
- **Kind**: static method of [<code>gulpConfig</code>](#module_gulpConfig)
472
-
473
- | Param | Type | Default |
474
- | --- | --- | --- |
475
- | path | <code>string</code> \| <code>null</code> | <code>null</code> |
476
- | defaultValue | <code>\*</code> | <code></code> |
477
-
478
- <a name="module_gulpConfig.set"></a>
479
-
480
- ### gulpConfig.set(path, value) ⇒ <code>\*</code>
481
- Specify a value for the configurations to use.
482
-
483
- **Kind**: static method of [<code>gulpConfig</code>](#module_gulpConfig)
484
-
485
- | Param |
486
- | --- |
487
- | path |
488
- | value |
489
-
490
- <a name="module_gulpConfig..ArrayableSetting"></a>
491
-
492
- ### gulpConfig~ArrayableSetting : <code>Array.&lt;string&gt;</code> \| <code>string</code>
493
- A setting that may be an array of strings or a string only.
494
-
495
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
496
- <a name="module_gulpConfig..BooleanSetting"></a>
497
-
498
- ### gulpConfig~BooleanSetting : <code>boolean</code>
499
- A setting that may be true or false.
500
-
501
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
502
- <a name="module_gulpConfig..FlagStringSetting"></a>
503
-
504
- ### gulpConfig~FlagStringSetting : <code>false</code> \| <code>StringSetting</code>
505
- A setting that may be flag 'false' or provide a StringSetting
506
-
507
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
508
- <a name="module_gulpConfig..FlagsSetting"></a>
509
-
510
- ### gulpConfig~FlagsSetting : <code>Object.&lt;string, BooleanSetting&gt;</code>
511
- An object of boolean settings used as flags.
512
-
513
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
514
- <a name="module_gulpConfig..JestTestFlags"></a>
515
-
516
- ### gulpConfig~JestTestFlags : <code>FlagsSetting</code>
517
- Configure cli options for running Jest.
518
-
519
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
520
- **Properties**
521
-
522
- | Name | Type |
523
- | --- | --- |
524
- | clearCache | <code>BooleanSetting</code> |
525
- | debug | <code>BooleanSetting</code> |
526
- | ignoreProjects: | <code>BooleanSetting</code> |
527
- | json | <code>BooleanSetting</code> |
528
- | selectProjects | <code>BooleanSetting</code> |
529
- | showConfig | <code>BooleanSetting</code> |
530
- | useStderr | <code>BooleanSetting</code> |
531
- | watch | <code>BooleanSetting</code> |
532
- | watchAll | <code>BooleanSetting</code> |
533
-
534
- <a name="module_gulpConfig..StringSetting"></a>
535
-
536
- ### gulpConfig~StringSetting : <code>string</code>
537
- A setting that may only be a string.
538
-
539
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
540
- <a name="module_gulpConfig..Setting"></a>
541
-
542
- ### gulpConfig~Setting : <code>ArrayableSetting</code> \| <code>BooleanSetting</code> \| <code>FlagsSetting</code> \| <code>StringSetting</code>
543
- Any single configuration option is a Setting.
544
-
545
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
546
- <a name="module_gulpConfig..BrowserConfig"></a>
547
-
548
- ### gulpConfig~BrowserConfig : <code>Object.&lt;string, Setting&gt;</code>
549
- Configurations for building the browser files.
550
-
551
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
552
- **Properties**
553
-
554
- | Name | Type | Description |
555
- | --- | --- | --- |
556
- | enabled | <code>BooleanSetting</code> | 'true' to generate browser bundled files; 'false' for node environment only |
557
- | from | <code>StringSetting</code> | The name to use for the browser-bundled output file (.js will be appended). |
558
- | name | <code>StringSetting</code> | The search pattern used for retrieving compiled distribution files. |
559
- | to | <code>StringSetting</code> | The output directory for browser-bundled files. |
560
-
561
- <a name="module_gulpConfig..DistConfig"></a>
562
-
563
- ### gulpConfig~DistConfig : <code>Object.&lt;string, Setting&gt;</code>
564
- Configurations for building the node distribution files.
565
-
566
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
567
- **Properties**
568
-
569
- | Name | Type | Description |
570
- | --- | --- | --- |
571
- | from | <code>StringSetting</code> | The search pattern used for gathering source files for distribution. |
572
- | main | <code>StringSetting</code> | Name of the entry the distribution file. |
573
- | to | <code>StringSetting</code> | The output directory for the distribution files. |
574
-
575
- <a name="module_gulpConfig..FontConfig"></a>
576
-
577
- ### gulpConfig~FontConfig : <code>Object.&lt;string, Setting&gt;</code>
578
- Configurations for copying the font files.
579
-
580
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
581
- **Properties**
582
-
583
- | Name | Type | Description |
584
- | --- | --- | --- |
585
- | enabled | <code>BooleanSetting</code> | Toggle copy directory of fonts on. |
586
- | from | <code>StringSetting</code> | Path to search for fonts. |
587
- | to | <code>StringSetting</code> | Path to output fonts. |
588
-
589
- <a name="module_gulpConfig..ImageConfig"></a>
590
-
591
- ### gulpConfig~ImageConfig : <code>Object.&lt;string, Setting&gt;</code>
592
- Configurations to minify and copy the images.
593
-
594
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
595
- **Properties**
596
-
597
- | Name | Type | Description |
598
- | --- | --- | --- |
599
- | enabled | <code>BooleanSetting</code> | Toggle image minify and copy process. |
600
- | from | <code>StringSetting</code> | Path to search for images. |
601
- | to | <code>StringSetting</code> | Path to output images. |
602
-
603
- <a name="module_gulpConfig..ReadmeConfig"></a>
604
-
605
- ### gulpConfig~ReadmeConfig : <code>Object.&lt;string, Setting&gt;</code>
606
- Configurations to compile and generate the Readme file.
607
-
608
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
609
- **Properties**
610
-
611
- | Name | Type | Description |
612
- | --- | --- | --- |
613
- | file | <code>StringSetting</code> | The name of the output documentation markdown file. |
614
- | from | <code>StringSetting</code> | Location of files to use for compiling documentation into the readme. |
615
- | options | <code>ArrayableSetting</code> | Options for formatting the output readme. |
616
- | template | <code>StringSetting</code> | The file which will be pre-fixed to your README.md output. |
617
- | to | <code>StringSetting</code> | The directory to output the readme file in. |
618
-
619
- <a name="module_gulpConfig..SassConfig"></a>
620
-
621
- ### gulpConfig~SassConfig : <code>Object.&lt;string, Setting&gt;</code>
622
- Configurations to compile and copy the sass files into css.
623
-
624
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
625
- **Properties**
626
-
627
- | Name | Type | Description |
628
- | --- | --- | --- |
629
- | enabled | <code>BooleanSetting</code> | Toggle SASS to CSS process on. |
630
- | from | <code>StringSetting</code> | The pattern for finding all sass files. |
631
- | path | <code>StringSetting</code> | The directory were sass files will be stored. |
632
- | to | <code>StringSetting</code> | The destination path for where generated CSS (from SASS files) should go. |
633
-
634
- <a name="module_gulpConfig..TestConfig"></a>
635
-
636
- ### gulpConfig~TestConfig : <code>Object.&lt;string, Setting&gt;</code>
637
- Configurations for running the test suite.
638
-
639
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
640
- **Properties**
641
-
642
- | Name | Type | Description |
643
- | --- | --- | --- |
644
- | options | <code>JestTestFlags</code> | Additional flags for programmatically running Jest Cli. |
645
- | path | <code>ArrayableSetting</code> | The directory where Jest test files are stored. By default, stored as *.test.js adjacent to the files they are testing. |
646
- | watch | <code>ArrayableSetting</code> | The search pattern for watching files for changes. |
647
-
648
- <a name="module_gulpConfig..TsConfig"></a>
649
-
650
- ### gulpConfig~TsConfig : <code>Object.&lt;string, Setting&gt;</code>
651
- Configurations for compiling typescript into JS files.
652
-
653
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
654
- **Properties**
655
-
656
- | Name | Type | Description |
657
- | --- | --- | --- |
658
- | config | <code>FlagStringSetting</code> | The path the tsconfig file for running typescript or false if no ts file given. |
659
- | enabled | <code>BooleanSetting</code> | Toggle usage of typescript parsing. |
660
- | from | <code>StringSetting</code> | Pattern for finding the TypeScript files. |
661
- | to | <code>StringSetting</code> | Directory where parsed typescript files go. |
662
-
663
- <a name="module_gulpConfig..Configurations"></a>
664
-
665
- ### gulpConfig~Configurations : <code>Object.&lt;string, Setting&gt;</code>
666
- A set of Configurations options defined by Settings.
667
-
668
- **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
669
- **Properties**
670
-
671
- | Name | Type | Description |
672
- | --- | --- | --- |
673
- | browser | <code>BrowserConfig</code> | Browser bundling configuration group. |
674
- | cleanPaths | <code>ArrayableSetting</code> | The paths for directories to delete before build. |
675
- | dist | <code>DistConfig</code> | Distribution file generation configuration group. |
676
- | fonts | <code>FontConfig</code> | Fonts copy configuration group. |
677
- | images | <code>ImageConfig</code> | Minify and copy the images configuration. |
678
- | readme | <code>ReadmeConfig</code> | Build readme files configuration. |
679
- | rootPath | <code>StringSetting</code> | Base directory of the project. |
680
- | sass | <code>SassConfig</code> | Compile CSS from SASS configuration. |
681
- | srcPath | <code>StringSetting</code> | The directory where your source files are stored (the files you manually created). |
682
- | test | <code>TestConfig</code> | Run test suite configuration. |
683
- | typescript | <code>TsConfig</code> | Compile from typescript configuration. |
684
-
411
+ ## Modules
412
+
413
+ <dl>
414
+ <dt><a href="#module_js-build-tools">js-build-tools</a></dt>
415
+ <dd><p>Export these functions to your own project to customize your build pipeline.</p>
416
+ </dd>
417
+ <dt><a href="#module_gulpConfig">gulpConfig</a></dt>
418
+ <dd><p>Modify these configurations to match your project specifications.</p>
419
+ </dd>
420
+ </dl>
421
+
422
+ <a name="module_js-build-tools"></a>
423
+
424
+ ## js-build-tools
425
+ Export these functions to your own project to customize your build pipeline.
426
+
427
+ **Version**: 3.0.0
428
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
429
+ <a name="module_js-build-tools.build"></a>
430
+
431
+ ### js-build-tools.build() ⇒ <code>stream.Stream</code>
432
+ Runs several processes to build and validate the project.
433
+
434
+ **Kind**: static method of [<code>js-build-tools</code>](#module_js-build-tools)
435
+ <a name="module_gulpConfig"></a>
436
+
437
+ ## gulpConfig
438
+ Modify these configurations to match your project specifications.
439
+
440
+ **Version**: 3.0.0
441
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
442
+
443
+ * [gulpConfig](#module_gulpConfig)
444
+ * _static_
445
+ * [.get(path, defaultValue)](#module_gulpConfig.get) ⇒ <code>\*</code> \| <code>null</code>
446
+ * [.set(path, value)](#module_gulpConfig.set) ⇒ <code>\*</code>
447
+ * _inner_
448
+ * [~ArrayableSetting](#module_gulpConfig..ArrayableSetting) : <code>Array.&lt;string&gt;</code> \| <code>string</code>
449
+ * [~BooleanSetting](#module_gulpConfig..BooleanSetting) : <code>boolean</code>
450
+ * [~FlagStringSetting](#module_gulpConfig..FlagStringSetting) : <code>false</code> \| <code>StringSetting</code>
451
+ * [~FlagsSetting](#module_gulpConfig..FlagsSetting) : <code>Object.&lt;string, BooleanSetting&gt;</code>
452
+ * [~JestTestFlags](#module_gulpConfig..JestTestFlags) : <code>FlagsSetting</code>
453
+ * [~StringSetting](#module_gulpConfig..StringSetting) : <code>string</code>
454
+ * [~Setting](#module_gulpConfig..Setting) : <code>ArrayableSetting</code> \| <code>BooleanSetting</code> \| <code>FlagsSetting</code> \| <code>StringSetting</code>
455
+ * [~BrowserConfig](#module_gulpConfig..BrowserConfig) : <code>Object.&lt;string, Setting&gt;</code>
456
+ * [~DistConfig](#module_gulpConfig..DistConfig) : <code>Object.&lt;string, Setting&gt;</code>
457
+ * [~FontConfig](#module_gulpConfig..FontConfig) : <code>Object.&lt;string, Setting&gt;</code>
458
+ * [~ImageConfig](#module_gulpConfig..ImageConfig) : <code>Object.&lt;string, Setting&gt;</code>
459
+ * [~ReadmeConfig](#module_gulpConfig..ReadmeConfig) : <code>Object.&lt;string, Setting&gt;</code>
460
+ * [~SassConfig](#module_gulpConfig..SassConfig) : <code>Object.&lt;string, Setting&gt;</code>
461
+ * [~TestConfig](#module_gulpConfig..TestConfig) : <code>Object.&lt;string, Setting&gt;</code>
462
+ * [~TsConfig](#module_gulpConfig..TsConfig) : <code>Object.&lt;string, Setting&gt;</code>
463
+ * [~Configurations](#module_gulpConfig..Configurations) : <code>Object.&lt;string, Setting&gt;</code>
464
+
465
+ <a name="module_gulpConfig.get"></a>
466
+
467
+ ### gulpConfig.get(path, defaultValue) ⇒ <code>\*</code> \| <code>null</code>
468
+ Retrieve a value from the configurations, default may be returned.
469
+
470
+ **Kind**: static method of [<code>gulpConfig</code>](#module_gulpConfig)
471
+
472
+ | Param | Type | Default |
473
+ | --- | --- | --- |
474
+ | path | <code>string</code> \| <code>null</code> | <code>null</code> |
475
+ | defaultValue | <code>\*</code> | <code></code> |
476
+
477
+ <a name="module_gulpConfig.set"></a>
478
+
479
+ ### gulpConfig.set(path, value) ⇒ <code>\*</code>
480
+ Specify a value for the configurations to use.
481
+
482
+ **Kind**: static method of [<code>gulpConfig</code>](#module_gulpConfig)
483
+
484
+ | Param |
485
+ | --- |
486
+ | path |
487
+ | value |
488
+
489
+ <a name="module_gulpConfig..ArrayableSetting"></a>
490
+
491
+ ### gulpConfig~ArrayableSetting : <code>Array.&lt;string&gt;</code> \| <code>string</code>
492
+ A setting that may be an array of strings or a string only.
493
+
494
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
495
+ <a name="module_gulpConfig..BooleanSetting"></a>
496
+
497
+ ### gulpConfig~BooleanSetting : <code>boolean</code>
498
+ A setting that may be true or false.
499
+
500
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
501
+ <a name="module_gulpConfig..FlagStringSetting"></a>
502
+
503
+ ### gulpConfig~FlagStringSetting : <code>false</code> \| <code>StringSetting</code>
504
+ A setting that may be flag 'false' or provide a StringSetting
505
+
506
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
507
+ <a name="module_gulpConfig..FlagsSetting"></a>
508
+
509
+ ### gulpConfig~FlagsSetting : <code>Object.&lt;string, BooleanSetting&gt;</code>
510
+ An object of boolean settings used as flags.
511
+
512
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
513
+ <a name="module_gulpConfig..JestTestFlags"></a>
514
+
515
+ ### gulpConfig~JestTestFlags : <code>FlagsSetting</code>
516
+ Configure cli options for running Jest.
517
+
518
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
519
+ **Properties**
520
+
521
+ | Name | Type |
522
+ | --- | --- |
523
+ | clearCache | <code>BooleanSetting</code> |
524
+ | debug | <code>BooleanSetting</code> |
525
+ | ignoreProjects: | <code>BooleanSetting</code> |
526
+ | json | <code>BooleanSetting</code> |
527
+ | selectProjects | <code>BooleanSetting</code> |
528
+ | showConfig | <code>BooleanSetting</code> |
529
+ | useStderr | <code>BooleanSetting</code> |
530
+ | watch | <code>BooleanSetting</code> |
531
+ | watchAll | <code>BooleanSetting</code> |
532
+
533
+ <a name="module_gulpConfig..StringSetting"></a>
534
+
535
+ ### gulpConfig~StringSetting : <code>string</code>
536
+ A setting that may only be a string.
537
+
538
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
539
+ <a name="module_gulpConfig..Setting"></a>
540
+
541
+ ### gulpConfig~Setting : <code>ArrayableSetting</code> \| <code>BooleanSetting</code> \| <code>FlagsSetting</code> \| <code>StringSetting</code>
542
+ Any single configuration option is a Setting.
543
+
544
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
545
+ <a name="module_gulpConfig..BrowserConfig"></a>
546
+
547
+ ### gulpConfig~BrowserConfig : <code>Object.&lt;string, Setting&gt;</code>
548
+ Configurations for building the browser files.
549
+
550
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
551
+ **Properties**
552
+
553
+ | Name | Type | Description |
554
+ | --- | --- | --- |
555
+ | enabled | <code>BooleanSetting</code> | 'true' to generate browser bundled files; 'false' for node environment only |
556
+ | from | <code>StringSetting</code> | The name to use for the browser-bundled output file (.js will be appended). |
557
+ | name | <code>StringSetting</code> | The search pattern used for retrieving compiled distribution files. |
558
+ | to | <code>StringSetting</code> | The output directory for browser-bundled files. |
559
+
560
+ <a name="module_gulpConfig..DistConfig"></a>
561
+
562
+ ### gulpConfig~DistConfig : <code>Object.&lt;string, Setting&gt;</code>
563
+ Configurations for building the node distribution files.
564
+
565
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
566
+ **Properties**
567
+
568
+ | Name | Type | Description |
569
+ | --- | --- | --- |
570
+ | from | <code>StringSetting</code> | The search pattern used for gathering source files for distribution. |
571
+ | main | <code>StringSetting</code> | Name of the entry the distribution file. |
572
+ | to | <code>StringSetting</code> | The output directory for the distribution files. |
573
+
574
+ <a name="module_gulpConfig..FontConfig"></a>
575
+
576
+ ### gulpConfig~FontConfig : <code>Object.&lt;string, Setting&gt;</code>
577
+ Configurations for copying the font files.
578
+
579
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
580
+ **Properties**
581
+
582
+ | Name | Type | Description |
583
+ | --- | --- | --- |
584
+ | enabled | <code>BooleanSetting</code> | Toggle copy directory of fonts on. |
585
+ | from | <code>StringSetting</code> | Path to search for fonts. |
586
+ | to | <code>StringSetting</code> | Path to output fonts. |
587
+
588
+ <a name="module_gulpConfig..ImageConfig"></a>
589
+
590
+ ### gulpConfig~ImageConfig : <code>Object.&lt;string, Setting&gt;</code>
591
+ Configurations to minify and copy the images.
592
+
593
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
594
+ **Properties**
595
+
596
+ | Name | Type | Description |
597
+ | --- | --- | --- |
598
+ | enabled | <code>BooleanSetting</code> | Toggle image minify and copy process. |
599
+ | from | <code>StringSetting</code> | Path to search for images. |
600
+ | to | <code>StringSetting</code> | Path to output images. |
601
+
602
+ <a name="module_gulpConfig..ReadmeConfig"></a>
603
+
604
+ ### gulpConfig~ReadmeConfig : <code>Object.&lt;string, Setting&gt;</code>
605
+ Configurations to compile and generate the Readme file.
606
+
607
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
608
+ **Properties**
609
+
610
+ | Name | Type | Description |
611
+ | --- | --- | --- |
612
+ | file | <code>StringSetting</code> | The name of the output documentation markdown file. |
613
+ | from | <code>StringSetting</code> | Location of files to use for compiling documentation into the readme. |
614
+ | options | <code>ArrayableSetting</code> | Options for formatting the output readme. |
615
+ | template | <code>StringSetting</code> | The file which will be pre-fixed to your README.md output. |
616
+ | to | <code>StringSetting</code> | The directory to output the readme file in. |
617
+
618
+ <a name="module_gulpConfig..SassConfig"></a>
619
+
620
+ ### gulpConfig~SassConfig : <code>Object.&lt;string, Setting&gt;</code>
621
+ Configurations to compile and copy the sass files into css.
622
+
623
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
624
+ **Properties**
625
+
626
+ | Name | Type | Description |
627
+ | --- | --- | --- |
628
+ | enabled | <code>BooleanSetting</code> | Toggle SASS to CSS process on. |
629
+ | from | <code>StringSetting</code> | The pattern for finding all sass files. |
630
+ | path | <code>StringSetting</code> | The directory were sass files will be stored. |
631
+ | to | <code>StringSetting</code> | The destination path for where generated CSS (from SASS files) should go. |
632
+
633
+ <a name="module_gulpConfig..TestConfig"></a>
634
+
635
+ ### gulpConfig~TestConfig : <code>Object.&lt;string, Setting&gt;</code>
636
+ Configurations for running the test suite.
637
+
638
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
639
+ **Properties**
640
+
641
+ | Name | Type | Description |
642
+ | --- | --- | --- |
643
+ | options | <code>JestTestFlags</code> | Additional flags for programmatically running Jest Cli. |
644
+ | path | <code>ArrayableSetting</code> | The directory where Jest test files are stored. By default, stored as *.test.js adjacent to the files they are testing. |
645
+ | watch | <code>ArrayableSetting</code> | The search pattern for watching files for changes. |
646
+
647
+ <a name="module_gulpConfig..TsConfig"></a>
648
+
649
+ ### gulpConfig~TsConfig : <code>Object.&lt;string, Setting&gt;</code>
650
+ Configurations for compiling typescript into JS files.
651
+
652
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
653
+ **Properties**
654
+
655
+ | Name | Type | Description |
656
+ | --- | --- | --- |
657
+ | config | <code>FlagStringSetting</code> | The path the tsconfig file for running typescript or false if no ts file given. |
658
+ | enabled | <code>BooleanSetting</code> | Toggle usage of typescript parsing. |
659
+ | from | <code>StringSetting</code> | Pattern for finding the TypeScript files. |
660
+ | to | <code>StringSetting</code> | Directory where parsed typescript files go. |
661
+
662
+ <a name="module_gulpConfig..Configurations"></a>
663
+
664
+ ### gulpConfig~Configurations : <code>Object.&lt;string, Setting&gt;</code>
665
+ A set of Configurations options defined by Settings.
666
+
667
+ **Kind**: inner typedef of [<code>gulpConfig</code>](#module_gulpConfig)
668
+ **Properties**
669
+
670
+ | Name | Type | Description |
671
+ | --- | --- | --- |
672
+ | browser | <code>BrowserConfig</code> | Browser bundling configuration group. |
673
+ | cleanPaths | <code>ArrayableSetting</code> | The paths for directories to delete before build. |
674
+ | dist | <code>DistConfig</code> | Distribution file generation configuration group. |
675
+ | fonts | <code>FontConfig</code> | Fonts copy configuration group. |
676
+ | images | <code>ImageConfig</code> | Minify and copy the images configuration. |
677
+ | readme | <code>ReadmeConfig</code> | Build readme files configuration. |
678
+ | rootPath | <code>StringSetting</code> | Base directory of the project. |
679
+ | sass | <code>SassConfig</code> | Compile CSS from SASS configuration. |
680
+ | srcPath | <code>StringSetting</code> | The directory where your source files are stored (the files you manually created). |
681
+ | test | <code>TestConfig</code> | Run test suite configuration. |
682
+ | typescript | <code>TsConfig</code> | Compile from typescript configuration. |
683
+
package/dist/bundle.js CHANGED
@@ -13,8 +13,24 @@ function _interopRequireWildcard (e, t) { if (typeof WeakMap === 'function') var
13
13
  function _interopRequireDefault (e) { return e && e.__esModule ? e : { default: e } }
14
14
  /**
15
15
  * Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
16
+ *
17
+ * Two escape hatches from browser.config.json keep an unwanted dependency (or a dependency's dependency) out of the
18
+ * bundle: 'ignore' replaces it with an empty object (safe when your code never actually calls into it - for example
19
+ * a library's default option value you always override with your own) and 'exclude' leaves it out entirely (your
20
+ * code must not require it, or provide it another way, such as a separate script tag).
16
21
  * @memberOf module:js-build-tools
17
22
  * @returns {stream.Stream}
18
23
  */
19
- const bundle = () => (0, _browserify.default)(gulpConfig.get('dist.main')).bundle().pipe((0, _vinylSourceStream.default)(`${gulpConfig.get('browser.name')}.js`)).pipe((0, _gulp.dest)(gulpConfig.get('browser.to')))
24
+ const bundle = () => {
25
+ const bundler = (0, _browserify.default)(gulpConfig.get('dist.main'))
26
+ const ignore = gulpConfig.get('browser.ignore')
27
+ const exclude = gulpConfig.get('browser.exclude')
28
+ if (ignore && ignore.length) {
29
+ bundler.ignore(ignore)
30
+ }
31
+ if (exclude && exclude.length) {
32
+ bundler.exclude(exclude)
33
+ }
34
+ return bundler.bundle().pipe((0, _vinylSourceStream.default)(`${gulpConfig.get('browser.name')}.js`)).pipe((0, _gulp.dest)(gulpConfig.get('browser.to')))
35
+ }
20
36
  exports.bundle = bundle
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.bundle=void 0;var _browserify=_interopRequireDefault(require("browserify")),_gulp=require("gulp"),gulpConfig=_interopRequireWildcard(require("../gulp.config.js")),_vinylSourceStream=_interopRequireDefault(require("vinyl-source-stream"));function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,u=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var i,n,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(i=r?u:t){if(i.has(e))return i.get(e);i.set(e,o)}for(const r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((n=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,r))&&(n.get||n.set)?i(o,r,n):o[r]=e[r]);return o})(e,r)}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const bundle=()=>(0,_browserify.default)(gulpConfig.get("dist.main")).bundle().pipe((0,_vinylSourceStream.default)(`${gulpConfig.get("browser.name")}.js`)).pipe((0,_gulp.dest)(gulpConfig.get("browser.to")));exports.bundle=bundle;
1
+ "use strict";require("core-js/modules/esnext.weak-map.delete-all.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.bundle=void 0;var _browserify=_interopRequireDefault(require("browserify")),_gulp=require("gulp"),gulpConfig=_interopRequireWildcard(require("../gulp.config.js")),_vinylSourceStream=_interopRequireDefault(require("vinyl-source-stream"));function _interopRequireWildcard(e,r){if("function"==typeof WeakMap)var t=new WeakMap,u=new WeakMap;return(_interopRequireWildcard=function(e,r){if(!r&&e&&e.__esModule)return e;var n,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(n=r?u:t){if(n.has(e))return n.get(e);n.set(e,o)}for(const r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?n(o,r,i):o[r]=e[r]);return o})(e,r)}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const bundle=()=>{const e=(0,_browserify.default)(gulpConfig.get("dist.main")),r=gulpConfig.get("browser.ignore"),t=gulpConfig.get("browser.exclude");return r&&r.length&&e.ignore(r),t&&t.length&&e.exclude(t),e.bundle().pipe((0,_vinylSourceStream.default)(`${gulpConfig.get("browser.name")}.js`)).pipe((0,_gulp.dest)(gulpConfig.get("browser.to")))};exports.bundle=bundle;
@@ -5,10 +5,26 @@ import source from 'vinyl-source-stream'
5
5
 
6
6
  /**
7
7
  * Starting at the distribution entry point, bundle all the files into a single file and store them in the specified output directory.
8
+ *
9
+ * Two escape hatches from browser.config.json keep an unwanted dependency (or a dependency's dependency) out of the
10
+ * bundle: 'ignore' replaces it with an empty object (safe when your code never actually calls into it - for example
11
+ * a library's default option value you always override with your own) and 'exclude' leaves it out entirely (your
12
+ * code must not require it, or provide it another way, such as a separate script tag).
8
13
  * @memberOf module:js-build-tools
9
14
  * @returns {stream.Stream}
10
15
  */
11
- export const bundle = () => browserify(gulpConfig.get('dist.main'))
12
- .bundle()
13
- .pipe(source(`${gulpConfig.get('browser.name')}.js`))
14
- .pipe(dest(gulpConfig.get('browser.to')))
16
+ export const bundle = () => {
17
+ const bundler = browserify(gulpConfig.get('dist.main'))
18
+ const ignore = gulpConfig.get('browser.ignore')
19
+ const exclude = gulpConfig.get('browser.exclude')
20
+ if (ignore && ignore.length) {
21
+ bundler.ignore(ignore)
22
+ }
23
+ if (exclude && exclude.length) {
24
+ bundler.exclude(exclude)
25
+ }
26
+ return bundler
27
+ .bundle()
28
+ .pipe(source(`${gulpConfig.get('browser.name')}.js`))
29
+ .pipe(dest(gulpConfig.get('browser.to')))
30
+ }
@@ -67,3 +67,77 @@ describe('bundle', () => {
67
67
  })
68
68
  })
69
69
  })
70
+
71
+ describe('bundle ignore / exclude', () => {
72
+ const optionalDepMarker = 'MARKER_FROM_THE_OPTIONAL_DEPENDENCY_CODE'
73
+
74
+ beforeEach(() => {
75
+ const tempDir = gulpConfig.get('rootPath')
76
+ const depDir = `${tempDir}node_modules/optional-dep`
77
+ fs.mkdirSync(depDir, { recursive: true })
78
+ fs.writeFileSync(`${depDir}/package.json`, JSON.stringify({ name: 'optional-dep', main: 'index.js' }))
79
+ fs.writeFileSync(`${depDir}/index.js`, `module.exports = '${optionalDepMarker}'\n`)
80
+ const distPath = gulpConfig.get('dist.to')
81
+ const mainFile = gulpConfig.get('dist.main')
82
+ fs.mkdirSync(distPath, { recursive: true })
83
+ // Only reached as a fallback for an option the caller always overrides, the way css-select falls back to its
84
+ // own default adapter (domutils) unless one is given - exactly the case ignore / exclude exist for.
85
+ fs.writeFileSync(`${mainFile}.js`, 'const optionalDep = require(\'optional-dep\')\n\nmodule.exports = (given) => given || optionalDep\n')
86
+ })
87
+
88
+ test('without ignore or exclude, the dependency is bundled', done => {
89
+ const destPath = gulpConfig.get('browser.to')
90
+ const bundledFile = `${destPath}/${gulpConfig.get('browser.name')}.js`
91
+ expect.assertions(1)
92
+ bundle()
93
+ .on('finish', () => {
94
+ expect(fs.readFileSync(bundledFile).toString()).toContain(optionalDepMarker)
95
+ done()
96
+ })
97
+ .on('error', error => done(error))
98
+ })
99
+
100
+ test('ignore replaces the dependency with an empty object, but the bundle still finishes', done => {
101
+ gulpConfig.set('browser.ignore', ['optional-dep'])
102
+ const destPath = gulpConfig.get('browser.to')
103
+ const bundledFile = `${destPath}/${gulpConfig.get('browser.name')}.js`
104
+ expect.assertions(2)
105
+ bundle()
106
+ .on('finish', () => {
107
+ const bundledContents = fs.readFileSync(bundledFile).toString()
108
+ // The ignored module is still in the bundle (as an empty stub, so requiring it by name still resolves) -
109
+ // it just no longer has the real code that would have pulled in the marker
110
+ expect(bundledContents).toContain('optional-dep')
111
+ expect(bundledContents).not.toContain(optionalDepMarker)
112
+ done()
113
+ })
114
+ .on('error', error => done(error))
115
+ })
116
+
117
+ test('exclude leaves the dependency out of the bundle entirely', done => {
118
+ gulpConfig.set('browser.exclude', ['optional-dep'])
119
+ const destPath = gulpConfig.get('browser.to')
120
+ const bundledFile = `${destPath}/${gulpConfig.get('browser.name')}.js`
121
+ expect.assertions(1)
122
+ bundle()
123
+ .on('finish', () => {
124
+ expect(fs.readFileSync(bundledFile).toString()).not.toContain(optionalDepMarker)
125
+ done()
126
+ })
127
+ .on('error', error => done(error))
128
+ })
129
+
130
+ test('a single string is accepted the same as a one item array', done => {
131
+ gulpConfig.set('browser.ignore', 'optional-dep')
132
+ const destPath = gulpConfig.get('browser.to')
133
+ const bundledFile = `${destPath}/${gulpConfig.get('browser.name')}.js`
134
+ expect.assertions(1)
135
+ bundle()
136
+ .on('finish', () => {
137
+ expect(fs.readFileSync(bundledFile).toString()).not.toContain(optionalDepMarker)
138
+ done()
139
+ })
140
+ .on('error', error => done(error))
141
+ })
142
+ })
143
+
package/gulp.config.mjs CHANGED
@@ -52,6 +52,14 @@ import { fileExists } from 'test-filesystem'
52
52
  * @property {StringSetting} from - The name to use for the browser-bundled output file (.js will be appended).
53
53
  * @property {StringSetting} name - The search pattern used for retrieving compiled distribution files.
54
54
  * @property {StringSetting} to - The output directory for browser-bundled files.
55
+ * @property {ArrayableSetting} ignore - Module names or file paths which resolve to an empty object ({}) in the
56
+ * bundle instead of their real contents. For a dependency which is only reached because it is the default value of
57
+ * an option you always override (for example a selector engine's default DOM adapter, when you always pass your
58
+ * own), this keeps it (and anything only it requires) out of the bundle, as long as your code never actually reaches
59
+ * the real module by not overriding that option. See browserify's b.ignore(file).
60
+ * @property {ArrayableSetting} exclude - Module names or file paths left out of the bundle entirely; requiring one at
61
+ * runtime throws unless something else provides it (for example a script tag loading it separately). See
62
+ * browserify's b.exclude(file).
55
63
  */
56
64
  /**
57
65
  * Configurations for building the node distribution files.
@@ -130,7 +138,9 @@ import { readFileSync } from 'fs'
130
138
  const setDefaults = {
131
139
  browser: {
132
140
  enabled: true,
141
+ exclude: [],
133
142
  from: 'dist/**/*.js',
143
+ ignore: [],
134
144
  name: 'default',
135
145
  to: 'browser',
136
146
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-build-tools",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Standardised build process with gulp.",
5
5
  "main": "gulpfile.base.js",
6
6
  "exports": {