@polylith/builder 0.1.22 → 0.1.24
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/App.js +49 -16
- package/package.json +2 -2
package/App.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import {readFile, writeFile, stat} from 'node:fs/promises';
|
|
3
|
-
|
|
3
|
+
import express from 'express';
|
|
4
4
|
import * as rollup from 'rollup';
|
|
5
5
|
import { babel } from '@rollup/plugin-babel';
|
|
6
6
|
import * as resolve from '@rollup/plugin-node-resolve';
|
|
@@ -97,10 +97,24 @@ export default class App {
|
|
|
97
97
|
this.routerRoot = root;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Call this method to set the relative path from the project root, to a
|
|
102
|
+
* module that exports a default asynchrounsous method that takes an express
|
|
103
|
+
* router and will add to it the application specific routes.
|
|
104
|
+
*
|
|
105
|
+
* @param {String} modulePath
|
|
106
|
+
*/
|
|
100
107
|
setRouterModule(modulePath) {
|
|
101
108
|
this.modulePath = path.posix.join(this.root, modulePath);
|
|
102
109
|
}
|
|
103
110
|
|
|
111
|
+
/**
|
|
112
|
+
* This is called by the polylith server to setup routing for the
|
|
113
|
+
* application
|
|
114
|
+
*
|
|
115
|
+
* @param {express.Router} appRouter
|
|
116
|
+
* @returns {Promise}
|
|
117
|
+
*/
|
|
104
118
|
async router(appRouter) {
|
|
105
119
|
if (!this.modulePath) return;
|
|
106
120
|
|
|
@@ -161,7 +175,6 @@ export default class App {
|
|
|
161
175
|
codeBlock +=
|
|
162
176
|
` </script>
|
|
163
177
|
`
|
|
164
|
-
|
|
165
178
|
return codeBlock;
|
|
166
179
|
}
|
|
167
180
|
|
|
@@ -209,8 +222,8 @@ export default class App {
|
|
|
209
222
|
* inserted. To specify where the value should be inserted in the template
|
|
210
223
|
* file add the string "${variableName}" in the location.
|
|
211
224
|
*
|
|
212
|
-
* @param {
|
|
213
|
-
* @param {
|
|
225
|
+
* @param {String} name the name of the template variable
|
|
226
|
+
* @param {String} value that will be replaced
|
|
214
227
|
*/
|
|
215
228
|
setTemplateVariable(name, value) {
|
|
216
229
|
this.templateVariables[name] = value;
|
|
@@ -218,6 +231,7 @@ export default class App {
|
|
|
218
231
|
|
|
219
232
|
/**
|
|
220
233
|
* Call this to add a configuration object to the application
|
|
234
|
+
*
|
|
221
235
|
* @param {Object} config a configuration object that will be added to the
|
|
222
236
|
* configuration store. Use get from @polylith/config to access
|
|
223
237
|
*/
|
|
@@ -465,6 +479,9 @@ export default class App {
|
|
|
465
479
|
} else if (indexExists) this.featureIndexes.push(indexPath);
|
|
466
480
|
}
|
|
467
481
|
|
|
482
|
+
/**
|
|
483
|
+
* Call this method to load the features for building the application
|
|
484
|
+
*/
|
|
468
485
|
async buildFeatures() {
|
|
469
486
|
var features = this.features;
|
|
470
487
|
|
|
@@ -473,6 +490,9 @@ export default class App {
|
|
|
473
490
|
}
|
|
474
491
|
}
|
|
475
492
|
|
|
493
|
+
/**
|
|
494
|
+
* Call this method to load the features when building the tests
|
|
495
|
+
*/
|
|
476
496
|
async testFeatures() {
|
|
477
497
|
var features = this.features;
|
|
478
498
|
|
|
@@ -481,8 +501,8 @@ export default class App {
|
|
|
481
501
|
}
|
|
482
502
|
}
|
|
483
503
|
|
|
484
|
-
|
|
485
504
|
/**
|
|
505
|
+
* Call this method to add a module that can be loaded during runtime
|
|
486
506
|
*
|
|
487
507
|
* @param {String} root the relative path from the source root to the
|
|
488
508
|
* feature directory. Loadable paths are assumed to be relative to this
|
|
@@ -571,14 +591,15 @@ export default class App {
|
|
|
571
591
|
browser: true,
|
|
572
592
|
extensions: ['.js', '.jsx']
|
|
573
593
|
}),
|
|
574
|
-
commonjs(),
|
|
575
|
-
nodePolyfills(),
|
|
576
|
-
rollupJson(),
|
|
577
|
-
jsconfig(this.root),
|
|
578
594
|
babel({
|
|
579
595
|
presets: ['@babel/preset-react'],
|
|
580
596
|
babelHelpers: 'bundled',
|
|
597
|
+
extensions: ['.js', '.jsx'],
|
|
581
598
|
}),
|
|
599
|
+
commonjs(),
|
|
600
|
+
nodePolyfills(),
|
|
601
|
+
rollupJson(),
|
|
602
|
+
jsconfig(this.root),
|
|
582
603
|
svgr({svgo: false}),
|
|
583
604
|
loadConfigs(this.configs),
|
|
584
605
|
loader(this.loadables),
|
|
@@ -613,7 +634,6 @@ export default class App {
|
|
|
613
634
|
}
|
|
614
635
|
return '[name].js';
|
|
615
636
|
}.bind(this),
|
|
616
|
-
manualChunks: manualChunks,
|
|
617
637
|
},
|
|
618
638
|
},
|
|
619
639
|
watch : {
|
|
@@ -626,8 +646,7 @@ export default class App {
|
|
|
626
646
|
};
|
|
627
647
|
|
|
628
648
|
return config;
|
|
629
|
-
|
|
630
|
-
}
|
|
649
|
+
}
|
|
631
650
|
|
|
632
651
|
/**
|
|
633
652
|
* Call this method to create the configuration for building the app
|
|
@@ -658,14 +677,14 @@ export default class App {
|
|
|
658
677
|
browser: true,
|
|
659
678
|
extensions: ['.js', '.jsx']
|
|
660
679
|
}),
|
|
661
|
-
commonjs(),
|
|
662
|
-
nodePolyfills(),
|
|
663
|
-
rollupJson(),
|
|
664
|
-
jsconfig(this.root),
|
|
665
680
|
babel({
|
|
666
681
|
presets: ['@babel/preset-react'],
|
|
667
682
|
babelHelpers: 'bundled',
|
|
668
683
|
}),
|
|
684
|
+
commonjs(),
|
|
685
|
+
nodePolyfills(),
|
|
686
|
+
rollupJson(),
|
|
687
|
+
jsconfig(this.root),
|
|
669
688
|
svgr({svgo: false}),
|
|
670
689
|
loadConfigs(this.configs),
|
|
671
690
|
loader(this.loadables),
|
|
@@ -730,6 +749,11 @@ export default class App {
|
|
|
730
749
|
return config;
|
|
731
750
|
}
|
|
732
751
|
|
|
752
|
+
/**
|
|
753
|
+
* Call this method to build the tests for the application
|
|
754
|
+
*
|
|
755
|
+
* @returns true if successful, false otherwise
|
|
756
|
+
*/
|
|
733
757
|
async test() {
|
|
734
758
|
this.testing = true;
|
|
735
759
|
if (!this.testPath || !this.spec) {
|
|
@@ -748,6 +772,11 @@ export default class App {
|
|
|
748
772
|
return true;
|
|
749
773
|
}
|
|
750
774
|
|
|
775
|
+
/**
|
|
776
|
+
* Call this method to build the application
|
|
777
|
+
*
|
|
778
|
+
* @returns true if successful, false otherwise
|
|
779
|
+
*/
|
|
751
780
|
async build() {
|
|
752
781
|
this.testing = false;
|
|
753
782
|
await this.buildFeatures();
|
|
@@ -761,6 +790,10 @@ export default class App {
|
|
|
761
790
|
return true;
|
|
762
791
|
}
|
|
763
792
|
|
|
793
|
+
/**
|
|
794
|
+
* Call this method to watch the source for changes, and rebuild when they
|
|
795
|
+
* happen.
|
|
796
|
+
*/
|
|
764
797
|
watch() {
|
|
765
798
|
var watchConfig = {
|
|
766
799
|
...this.config.input,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polylith/builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "The polylith builder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@babel/preset-env": "^7.16.11",
|
|
14
14
|
"@babel/preset-react": "^7.16.7",
|
|
15
15
|
"@rollup/plugin-babel": "^5.3.0",
|
|
16
|
-
"@rollup/plugin-commonjs": "^
|
|
16
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
17
17
|
"@rollup/plugin-json": "^5.0.2",
|
|
18
18
|
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
19
19
|
"@svgr/rollup": "^6.5.1",
|