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 +273 -274
- package/dist/bundle.js +17 -1
- package/dist/bundle.min.js +1 -1
- package/functions/bundle.mjs +20 -4
- package/functions/bundle.test.mjs +74 -0
- package/gulp.config.mjs +10 -0
- package/package.json +1 -1
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
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
**
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
*
|
|
445
|
-
|
|
446
|
-
* [.
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
* [~
|
|
450
|
-
* [~
|
|
451
|
-
* [~
|
|
452
|
-
* [~
|
|
453
|
-
* [~
|
|
454
|
-
* [~
|
|
455
|
-
* [~
|
|
456
|
-
* [~
|
|
457
|
-
* [~
|
|
458
|
-
* [~
|
|
459
|
-
* [~
|
|
460
|
-
* [~
|
|
461
|
-
* [~
|
|
462
|
-
* [~
|
|
463
|
-
* [~
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
|
474
|
-
|
|
|
475
|
-
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
|
486
|
-
|
|
|
487
|
-
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
**
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
|
523
|
-
|
|
|
524
|
-
|
|
|
525
|
-
|
|
|
526
|
-
|
|
|
527
|
-
|
|
|
528
|
-
|
|
|
529
|
-
|
|
|
530
|
-
|
|
|
531
|
-
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
**
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
|
555
|
-
|
|
|
556
|
-
|
|
|
557
|
-
|
|
|
558
|
-
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
**
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
|
570
|
-
|
|
|
571
|
-
|
|
|
572
|
-
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
**
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
|
584
|
-
|
|
|
585
|
-
|
|
|
586
|
-
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
**
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
|
598
|
-
|
|
|
599
|
-
|
|
|
600
|
-
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
**
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
|
612
|
-
|
|
|
613
|
-
|
|
|
614
|
-
|
|
|
615
|
-
|
|
|
616
|
-
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
**
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
|
628
|
-
|
|
|
629
|
-
|
|
|
630
|
-
|
|
|
631
|
-
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
**
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
|
643
|
-
|
|
|
644
|
-
|
|
|
645
|
-
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
**
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
|
657
|
-
|
|
|
658
|
-
|
|
|
659
|
-
|
|
|
660
|
-
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
**
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
|
672
|
-
|
|
|
673
|
-
|
|
|
674
|
-
|
|
|
675
|
-
|
|
|
676
|
-
|
|
|
677
|
-
|
|
|
678
|
-
|
|
|
679
|
-
|
|
|
680
|
-
|
|
|
681
|
-
|
|
|
682
|
-
|
|
|
683
|
-
|
|
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.<string></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.<string, BooleanSetting></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.<string, Setting></code>
|
|
456
|
+
* [~DistConfig](#module_gulpConfig..DistConfig) : <code>Object.<string, Setting></code>
|
|
457
|
+
* [~FontConfig](#module_gulpConfig..FontConfig) : <code>Object.<string, Setting></code>
|
|
458
|
+
* [~ImageConfig](#module_gulpConfig..ImageConfig) : <code>Object.<string, Setting></code>
|
|
459
|
+
* [~ReadmeConfig](#module_gulpConfig..ReadmeConfig) : <code>Object.<string, Setting></code>
|
|
460
|
+
* [~SassConfig](#module_gulpConfig..SassConfig) : <code>Object.<string, Setting></code>
|
|
461
|
+
* [~TestConfig](#module_gulpConfig..TestConfig) : <code>Object.<string, Setting></code>
|
|
462
|
+
* [~TsConfig](#module_gulpConfig..TsConfig) : <code>Object.<string, Setting></code>
|
|
463
|
+
* [~Configurations](#module_gulpConfig..Configurations) : <code>Object.<string, Setting></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.<string></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.<string, BooleanSetting></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.<string, Setting></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.<string, Setting></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.<string, Setting></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.<string, Setting></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.<string, Setting></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.<string, Setting></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.<string, Setting></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.<string, Setting></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.<string, Setting></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 = () =>
|
|
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
|
package/dist/bundle.min.js
CHANGED
|
@@ -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,
|
|
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;
|
package/functions/bundle.mjs
CHANGED
|
@@ -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 = () =>
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
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
|
},
|