@polylith/builder 0.1.18 → 0.1.20

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 CHANGED
@@ -10,9 +10,7 @@ import svgr from '@svgr/rollup'
10
10
  import html from 'rollup-plugin-html';
11
11
  import livereload from 'rollup-plugin-livereload';
12
12
  import styles from "rollup-plugin-styles";
13
- import builtins from 'rollup-plugin-node-builtins';
14
- import globals from 'rollup-plugin-node-globals';
15
-
13
+ import nodePolyfills from 'rollup-plugin-polyfill-node';
16
14
  import loader from './plugin-loader.js';
17
15
  import mainHTML from './plugin-main-html.js';
18
16
  import features from './plugin-features.js';
@@ -46,7 +44,7 @@ export default class App {
46
44
  * folder from the root for rolled up files
47
45
  */
48
46
  constructor(name, config) {
49
- var {root, index, dest, spec, testDest} = config;
47
+ var {root, index, dest, spec, testDest=''} = config;
50
48
 
51
49
  root = forceToPosix(root);
52
50
  this.root = root;
@@ -61,7 +59,7 @@ export default class App {
61
59
  this.index = index;
62
60
  this.spec = spec;
63
61
  this.fullIndexPath = path.posix.join(root, index);
64
- this.fullSpecPath = path.posix.join(root, spec);
62
+ this.fullSpecPath = spec ? path.posix.join(root, spec) : undefined;
65
63
 
66
64
  this.loadables = [];
67
65
  this.features = [];
@@ -69,7 +67,7 @@ export default class App {
69
67
  this.configs = [];
70
68
  this.manualChunkType = 'function';
71
69
  this.manualChunks = [];
72
- this.files = new Files(this.sourcePath, this.destPath);
70
+ this.files = new Files(this.sourcePath, this.destPath, this.testPath);
73
71
  this.cssSpecs = [];
74
72
  this.cssFiles = [];
75
73
  this.liveReload = true;
@@ -250,7 +248,7 @@ export default class App {
250
248
  * Call this method to find all the css files specified by the css specs
251
249
  */
252
250
  async findMainCss() {
253
- var files = new Files(this.sourcePath, this.destPath)
251
+ var files = new Files(this.sourcePath, this.destPath, this.testPath)
254
252
 
255
253
  // Find all the files from the added css specs. Also add them to be copied
256
254
  this.cssSpecs.forEach(function(spec) {
@@ -574,8 +572,7 @@ export default class App {
574
572
  extensions: ['.js', '.jsx']
575
573
  }),
576
574
  commonjs(),
577
- globals(),
578
- builtins(),
575
+ nodePolyfills(),
579
576
  rollupJson(),
580
577
  jsconfig(this.root),
581
578
  babel({
@@ -587,7 +584,7 @@ export default class App {
587
584
  loader(this.loadables),
588
585
  features(this.featureIndexes),
589
586
  styles(),
590
- resources(this.name, this.files)
587
+ resources(this.name, this.files, true)
591
588
  ];
592
589
 
593
590
  var config = {
@@ -662,8 +659,7 @@ export default class App {
662
659
  extensions: ['.js', '.jsx']
663
660
  }),
664
661
  commonjs(),
665
- globals(),
666
- builtins(),
662
+ nodePolyfills(),
667
663
  rollupJson(),
668
664
  jsconfig(this.root),
669
665
  babel({
@@ -684,7 +680,7 @@ export default class App {
684
680
  destination: this.htmlTemplate.destination,
685
681
  templateVars: this.templateVariables,
686
682
  }),
687
- resources(this.name, this.files)
683
+ resources(this.name, this.files, false)
688
684
  ];
689
685
 
690
686
  if (this.liveReload) {
package/Files.js CHANGED
@@ -17,12 +17,17 @@ export default class Files {
17
17
  * destination directory
18
18
  * @param {String} src the abolute path to the applications source
19
19
  * directory
20
+ *
21
+ * @param {String} src the abolute path to the applications test
22
+ * directory
20
23
  */
21
- constructor(src, dest) {
24
+ constructor(src, dest, testDest) {
22
25
  this.dest = dest;
26
+ this.testDest = testDest;
23
27
  this.src = src;
24
28
  /** @type {CopyInfoList} */
25
29
  this.files = {};
30
+ this.testFiles = {};
26
31
  this.specs = [];
27
32
  }
28
33
 
@@ -66,6 +71,21 @@ export default class Files {
66
71
  return destFilename;
67
72
  }
68
73
 
74
+ makeTestDestination() {
75
+ var fullPath = searchRoot;
76
+ var relativePath = srcFilename.slice(fullPath.length + 1);
77
+ var destFilename = '';
78
+
79
+ if (spec.keepNest) {
80
+ destFilename = path.join(this.dest, spec.testDest, relativePath);
81
+ } else {
82
+ destFilename = path.join(this.dest, spec.testDest, path.basename(srcFilename));
83
+ }
84
+
85
+ return destFilename;
86
+
87
+ }
88
+
69
89
  /**
70
90
  * Call this method once per spec to add a list of files to the complete
71
91
  * list of all the files to be copied. If multiple files are found through
@@ -97,12 +117,14 @@ export default class Files {
97
117
  }
98
118
 
99
119
  var destination = this.makeDestination(searchRoot, spec, file);
120
+ var testDestination = this.makeTestDestination(searchRoot, spec, file);
100
121
  var uri = destination.slice(this.dest.length + 1);
101
122
 
102
123
  foundFiles[file] = {
103
124
  name: file,
104
125
  searchRoot: searchRoot,
105
126
  destFilename: destination,
127
+ testDestFilename: testDestination,
106
128
  uri: uri,
107
129
  spec: spec,
108
130
  }
@@ -132,10 +154,10 @@ export default class Files {
132
154
  *
133
155
  * @param {String} file the full path of the file to be copied
134
156
  */
135
- async copyOneFile(file, updated) {
157
+ async copyOneFile(file, updated, forTest) {
136
158
  file = forceToPosix(file);
137
159
 
138
- var destination = this.files[file] && this.files[file].destFilename;
160
+ var destination = forTest ? this.files[file] && this.files[file].testDestFilename : this.files[file] && this.files[file].destFilename;
139
161
 
140
162
  if (destination && updated) {
141
163
  console.log(`file ${file} updated, copied to ${destination}`);
@@ -191,15 +213,17 @@ export default class Files {
191
213
  /**
192
214
  * Call this method to copy all the files that have been specified by
193
215
  * calling addResourceSpec to their destination directories
216
+ *
217
+ * @param {Boolean} forTest set true if copying files to test destination
194
218
  */
195
- async copyFiles() {
219
+ async copyFiles(forTest) {
196
220
  await this.findAllFiles();
197
221
 
198
222
  var filenames = Object.keys(this.files);
199
223
 
200
224
  // using a for loop because we are making async calls
201
225
  for (let srcFilename of filenames) {
202
- let destFilename = this.files[srcFilename].destFilename;
226
+ let destFilename = forTest ? this.files[srcFilename].testDestFilename : this.files[srcFilename].destFilename;
203
227
  let destFilePath = path.dirname(destFilename);
204
228
 
205
229
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polylith/builder",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "The polylith builder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,8 +26,7 @@
26
26
  "rollup-plugin-html": "^0.2.1",
27
27
  "rollup-plugin-jsx": "^1.0.3",
28
28
  "rollup-plugin-livereload": "^2.0.5",
29
- "rollup-plugin-node-builtins": "^2.1.2",
30
- "rollup-plugin-node-globals": "^1.4.0",
29
+ "rollup-plugin-polyfill-node": "^0.11.0",
31
30
  "rollup-plugin-styles": "^4.0.0",
32
31
  "sass": "^1.43.4"
33
32
  }
@@ -6,7 +6,7 @@ var copied= {}
6
6
  * copy
7
7
  * @returns {Object} the plugin
8
8
  */
9
- export default function(name, files) {
9
+ export default function(name, files, forTest) {
10
10
  return {
11
11
  name: "copy-resources",
12
12
 
@@ -26,7 +26,7 @@ export default function(name, files) {
26
26
  if (copied[name]) return;
27
27
  return new Promise(async function (resolve, reject) {
28
28
  try {
29
- await files.copyFiles();
29
+ await files.copyFiles(forTest);
30
30
  resolve(true)
31
31
  copied[name] = true;
32
32
  } catch (e) {