@polylith/builder 0.0.21 → 0.0.23

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
@@ -1,4 +1,5 @@
1
1
  import path from 'path';
2
+ import fs from 'fs-extra';
2
3
 
3
4
  import * as rollup from 'rollup';
4
5
  import { babel } from '@rollup/plugin-babel';
@@ -9,8 +10,10 @@ import html from "rollup-plugin-html";
9
10
  import loader from './plugin-loader.js';
10
11
  import mainHTML from './plugin-main-html.js';
11
12
  import features from './plugin-features.js';
13
+ import config from './plugin-config.js';
12
14
  import styles from "rollup-plugin-styles";
13
15
 
16
+
14
17
  /**
15
18
  * call this method to get the path from the a filename, and force the file path
16
19
  * to use posix notation and remove all drive information. This will likely
@@ -55,6 +58,8 @@ export class App {
55
58
 
56
59
  this.name = name;
57
60
  this.index = index;
61
+ this.fullIndexPath = path.posix.join(root, index);
62
+
58
63
  this.loadables = [];
59
64
  this.featureIndexes = [];
60
65
  }
@@ -72,8 +77,8 @@ export class App {
72
77
  */
73
78
  rootPath(path) {
74
79
  var idx = path.indexOf(this.sourcePath);
75
- if (idx === 0) path.splice(0, length(this.sourcePath));
76
- if (path[0] === '/') path.splice(0, 1);
80
+ if (idx === 0) path = path.slice(this.sourcePath.length);
81
+ if (path[0] === '/') path = path.slice(1);
77
82
 
78
83
  return './' + path;
79
84
  }
@@ -105,7 +110,7 @@ export class App {
105
110
  }
106
111
  }
107
112
 
108
- if (indexExists) this.featureIndexes.push(this.rootPath(indexPath));
113
+ if (indexExists) this.featureIndexes.push(indexPath);
109
114
  }
110
115
 
111
116
  async buildFeatures() {
@@ -131,7 +136,7 @@ export class App {
131
136
  }
132
137
 
133
138
  buildConfiguration() {
134
- var input = [this.index];
139
+ var input = [this.fullIndexPath];
135
140
  this.loadables.forEach(function(path) {
136
141
  input.push(path.path);
137
142
  });
@@ -154,6 +159,7 @@ export class App {
154
159
  }),
155
160
  loader(this.loadables),
156
161
  features(this.featureIndexes),
162
+ config(),
157
163
  html({
158
164
  include: path.join(this.sourcePath, "**/*.html"),
159
165
  }),
@@ -183,6 +189,8 @@ export class App {
183
189
  await this.buildFeatures();
184
190
  var config = this.buildConfiguration();
185
191
 
192
+ console.log(JSON.stringify(config, null, ' '));
193
+
186
194
  const bundle = await rollup.rollup(config.input);
187
195
  await bundle.generate(config.output);
188
196
  await bundle.write(config.output);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polylith/builder",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "The polylith builder",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/plugin-config.js CHANGED
@@ -5,18 +5,24 @@ import rollupPluginutils from ('rollup-pluginutils');
5
5
  export default function config() {
6
6
  var opts = {};
7
7
 
8
- opts.include = '**/*.cfg'
8
+ opts.include = '**/*.pl-cfg'
9
9
 
10
10
  var filter = rollupPluginutils.createFilter(opts.include, opts.exclude);
11
11
 
12
12
  return {
13
13
  name: 'config',
14
14
 
15
+ resolveId (source, _, third) {
16
+ if (filter(source)) return source
17
+
18
+ return null;
19
+ },
20
+
15
21
  async load(id) {
16
22
  if (filter(id)) {
17
23
  console.log(id);
18
- return source;
19
- }
24
+ return '';
25
+ }
20
26
  }
21
27
  };
22
28
  }
@@ -2,12 +2,11 @@ function makeSource(features) {
2
2
 
3
3
  var importStatements = '';
4
4
  features.forEach(function(feature) {
5
- importStatements += `import from '${feature}'\n`;
5
+ importStatements += `import '${feature}'\n`;
6
6
  })
7
7
 
8
8
  var source = `${importStatements}`
9
9
 
10
- console.log(source);
11
10
  return source;
12
11
  }
13
12