@polylith/builder 0.0.34 → 0.0.36

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
@@ -6,6 +6,7 @@ import { babel } from '@rollup/plugin-babel';
6
6
  import * as resolve from '@rollup/plugin-node-resolve';
7
7
  import commonjs from '@rollup/plugin-commonjs';
8
8
  import html from 'rollup-plugin-html';
9
+ import livereload from 'rollup-plugin-livereload';
9
10
 
10
11
  import loader from './plugin-loader.js';
11
12
  import mainHTML from './plugin-main-html.js';
@@ -69,6 +70,7 @@ export default class App {
69
70
  this.manualChunks = [];
70
71
  this.files = new Files(this.sourcePath, this.destPath);
71
72
  this.cssFiles = [];
73
+ this.liveReload = true;
72
74
  }
73
75
 
74
76
  static fileToPath(filename) {
@@ -107,6 +109,9 @@ export default class App {
107
109
  return './' + path;
108
110
  }
109
111
 
112
+ setLiveReload(on) {
113
+ this.liveReload = on;
114
+ }
110
115
  setHtmlTemplate(source, destination) {
111
116
  this.htmlTemplate = {source: source, destination: destination};
112
117
  }
@@ -160,7 +165,7 @@ export default class App {
160
165
  * If present that json will be loaded and used to build the feature.
161
166
  *
162
167
  * If that is not found it will look for an index.js file. and if found it
163
- * will add that to the list on feature index files which will be
168
+ * will add that to the list of feature index files which will be
164
169
  * automatically imported when the built code imports the @polylith/features
165
170
  * module
166
171
  *
@@ -399,34 +404,41 @@ export default class App {
399
404
 
400
405
  var manualChunks = this.getManualChunks();
401
406
  var mainCss = this.buildMainCss();
407
+ var plugins = [
408
+ resolve.nodeResolve({
409
+ extensions: ['.js', '.jsx']
410
+ }),
411
+ commonjs(),
412
+ babel({
413
+ presets: ['@babel/preset-react'],
414
+ babelHelpers: 'bundled',
415
+ }),
416
+ loader(this.loadables),
417
+ features(this.featureIndexes),
418
+ jsconfig(this.root),
419
+ html({
420
+ include: path.join(this.sourcePath, "**/*.html"),
421
+ }),
422
+ styles(),
423
+ mainHTML({
424
+ root: this.root,
425
+ source: this.htmlTemplate.source,
426
+ destination: this.htmlTemplate.destination,
427
+ replaceVars: {mainCss: mainCss},
428
+ }),
429
+ resources(this.name, this.files)
430
+ ];
431
+
432
+ if (this.liveReload) {
433
+ plugins.push(
434
+ liveReload(this.destPath)
435
+ )
436
+ }
402
437
 
403
438
  var config = {
404
439
  input : {
405
440
  input: input,
406
- plugins: [
407
- resolve.nodeResolve({
408
- extensions: ['.js', '.jsx']
409
- }),
410
- commonjs(),
411
- babel({
412
- presets: ['@babel/preset-react'],
413
- babelHelpers: 'bundled',
414
- }),
415
- loader(this.loadables),
416
- features(this.featureIndexes),
417
- jsconfig(this.root),
418
- html({
419
- include: path.join(this.sourcePath, "**/*.html"),
420
- }),
421
- styles(),
422
- mainHTML({
423
- root: this.root,
424
- source: this.htmlTemplate.source,
425
- destination: this.htmlTemplate.destination,
426
- replaceVars: {mainCss: mainCss},
427
- }),
428
- resources(this.name, this.files)
429
- ],
441
+ plugins: plugins,
430
442
  },
431
443
  output : {
432
444
  output : {
@@ -493,14 +505,13 @@ export default class App {
493
505
  }
494
506
 
495
507
  if (event.code === 'BUNDLE_START') {
496
- process.stdout.write("\u001b[2J\u001b[0;0H");
497
- console.log(event);
508
+ // console.log(event);
498
509
  }
499
510
 
500
511
  if (event.code === 'BUNDLE_END') {
501
- process.stdout.write("\u001b[2J\u001b[0;0H");
502
- console.log(event);
512
+ // console.log(event);
503
513
  }
504
514
  }.bind(this));
505
515
  }
516
+
506
517
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polylith/builder",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "description": "The polylith builder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,6 +23,7 @@
23
23
  "rollup": "^2.58.0",
24
24
  "rollup-plugin-html": "^0.2.1",
25
25
  "rollup-plugin-jsx": "^1.0.3",
26
+ "rollup-plugin-livereload": "^2.0.5",
26
27
  "rollup-plugin-styles": "^4.0.0",
27
28
  "sass": "^1.43.4"
28
29
  }
@@ -83,7 +83,7 @@ async function findPathMatch(base, source, paths) {
83
83
  }
84
84
 
85
85
 
86
- export default function features(root) {
86
+ export default function jsconfig(root) {
87
87
  var jsConfig;
88
88
  var basePath;
89
89
  var paths;
@@ -111,7 +111,7 @@ export default function features(root) {
111
111
 
112
112
 
113
113
  return {
114
- name: 'features',
114
+ name: 'jsconfig',
115
115
 
116
116
  async resolveId (source, importer, options) {
117
117
  source = fixPath(source);
@@ -125,6 +125,7 @@ export default function features(root) {
125
125
 
126
126
  if (basePath) {
127
127
  var tryName = path.join(root, basePath, source);
128
+ console.log('trying', tryName)
128
129
  if (await fileExists(tryName)) {
129
130
  previouslyMatched[source] = tryName;
130
131
  return tryName;