@polylith/builder 0.0.39 → 0.0.40
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 +17 -11
- package/index.js +1 -1
- package/package.json +1 -1
- package/plugin-config.js +44 -0
- package/plugin-copy-resources.js +1 -1
- package/utils.js +1 -1
package/App.js
CHANGED
|
@@ -14,6 +14,7 @@ import mainHTML from './plugin-main-html.js';
|
|
|
14
14
|
import features from './plugin-features.js';
|
|
15
15
|
import resources from "./plugin-copy-resources.js";
|
|
16
16
|
import jsconfig from "./plugin-jsconfig.js";
|
|
17
|
+
import loadConfigs from "./plugin-config.js";
|
|
17
18
|
|
|
18
19
|
import {forceToPosix, fileExists} from './utils.js'
|
|
19
20
|
import ConfigFeature from './ConfigFeature.js';
|
|
@@ -49,7 +50,7 @@ export default class App {
|
|
|
49
50
|
this.loadables = [];
|
|
50
51
|
this.features = [];
|
|
51
52
|
this.featureIndexes = [];
|
|
52
|
-
this.configs =
|
|
53
|
+
this.configs = [];
|
|
53
54
|
this.manualChunkType = 'function';
|
|
54
55
|
this.manualChunks = [];
|
|
55
56
|
this.files = new Files(this.sourcePath, this.destPath);
|
|
@@ -57,8 +58,7 @@ export default class App {
|
|
|
57
58
|
this.cssFiles = [];
|
|
58
59
|
this.liveReload = true;
|
|
59
60
|
this.templateVariables = {};
|
|
60
|
-
this.ns = name.toUpperCase();
|
|
61
|
-
this.ns = this.ns.replace(/[- ]*?/g, '_');
|
|
61
|
+
this.ns = name.replace(/[- ]+/g, '_').toUpperCase();
|
|
62
62
|
this.codeVariables = {};
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -100,13 +100,13 @@ export default class App {
|
|
|
100
100
|
if (names.length === 0) return '';
|
|
101
101
|
|
|
102
102
|
var members = names.map(function(name) {
|
|
103
|
-
return `
|
|
103
|
+
return ` ${name}: ${JSON.stringify(this.codeVariables[name])},`
|
|
104
104
|
}, this);
|
|
105
105
|
|
|
106
106
|
var codeBlock =
|
|
107
|
-
`
|
|
107
|
+
` window.${this.ns} = {
|
|
108
108
|
${members.join('\n')}
|
|
109
|
-
|
|
109
|
+
}
|
|
110
110
|
`;
|
|
111
111
|
return codeBlock;
|
|
112
112
|
}
|
|
@@ -162,8 +162,13 @@ ${members.join('\n')}
|
|
|
162
162
|
this.templateVariables[name] = value;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Call this to add a configuration object to the application
|
|
167
|
+
* @param {Object} config a configuration object that will be added to the
|
|
168
|
+
* configuration store. Use get from @polylith/config to access
|
|
169
|
+
*/
|
|
170
|
+
addConfig(config) {
|
|
171
|
+
this.configs.push(config);
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
/**
|
|
@@ -184,7 +189,7 @@ ${members.join('\n')}
|
|
|
184
189
|
var files = new Files(this.sourcePath, this.destPath)
|
|
185
190
|
|
|
186
191
|
// Find all the files frem the added css speces
|
|
187
|
-
|
|
192
|
+
this.cssSpecs.forEach(function(spec) {
|
|
188
193
|
files.addResourceSpec('', spec);
|
|
189
194
|
}, this)
|
|
190
195
|
|
|
@@ -196,7 +201,7 @@ ${members.join('\n')}
|
|
|
196
201
|
}, this);
|
|
197
202
|
|
|
198
203
|
// now add them to be copied
|
|
199
|
-
this.addResources('',
|
|
204
|
+
this.addResources('', this.cssSpecs);
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
/**
|
|
@@ -477,7 +482,7 @@ ${members.join('\n')}
|
|
|
477
482
|
var input = [this.fullIndexPath];
|
|
478
483
|
|
|
479
484
|
// using a for loop because we are making an async call
|
|
480
|
-
for (let loadable of loadables) {
|
|
485
|
+
for (let loadable of this.loadables) {
|
|
481
486
|
// find all the css files for the loadables
|
|
482
487
|
await this.findLoadableCss(loadable);
|
|
483
488
|
input.push(loadable.index);
|
|
@@ -499,6 +504,7 @@ ${members.join('\n')}
|
|
|
499
504
|
presets: ['@babel/preset-react'],
|
|
500
505
|
babelHelpers: 'bundled',
|
|
501
506
|
}),
|
|
507
|
+
loadConfigs(this.configs),
|
|
502
508
|
loader(this.loadables),
|
|
503
509
|
features(this.featureIndexes),
|
|
504
510
|
jsconfig(this.root),
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import App from './App.js'
|
|
|
2
2
|
import Feature from './Feature.js';
|
|
3
3
|
import ConfigApp from './ConfigApp.js';
|
|
4
4
|
import ConfigFeature from './ConfigFeature.js';
|
|
5
|
-
import utils from './utils.js';
|
|
5
|
+
import * as utils from './utils.js';
|
|
6
6
|
|
|
7
7
|
var utilsExport = {
|
|
8
8
|
forceToPosix: utils.forceToPosix,
|
package/package.json
CHANGED
package/plugin-config.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import config from '@polylith/config-store';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function makeSource(configs) {
|
|
5
|
+
|
|
6
|
+
var configBody = ''
|
|
7
|
+
|
|
8
|
+
configs.forEach(function(config) {
|
|
9
|
+
configBody +=
|
|
10
|
+
`config.add(
|
|
11
|
+
${JSON.stringify(config, null, ' ')})
|
|
12
|
+
|
|
13
|
+
`
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
var source =
|
|
17
|
+
`import config from '@polylith/config-store';
|
|
18
|
+
export var config;
|
|
19
|
+
|
|
20
|
+
${configBody}
|
|
21
|
+
`
|
|
22
|
+
console.log(source);
|
|
23
|
+
return source;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function loadConfigs(configs) {
|
|
27
|
+
return {
|
|
28
|
+
name: 'config',
|
|
29
|
+
|
|
30
|
+
resolveId (source, _, third) {
|
|
31
|
+
if (source === '@polylith/config') {
|
|
32
|
+
return source;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
async load (id) {
|
|
38
|
+
if (id === '@polylith/config') {
|
|
39
|
+
return makeSource(configs);
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
package/plugin-copy-resources.js
CHANGED