@easyv/react-component-builder 0.19.4 → 0.19.5-beta.1

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/launcher/build.js CHANGED
@@ -26,7 +26,7 @@ module.exports = (name, option = {}) => {
26
26
  const result = await getBuildEntrys();
27
27
  const componentInfo = result.find((d) => d.name === name);
28
28
  const { base } = componentInfo;
29
- const pathSymbol = os.type() === 'Windows_NT' ? "\\" : "/"
29
+ const pathSymbol = os.type() === 'Windows_NT' ? '\\' : '/';
30
30
  const sourcePath = componentInfo.path.slice(
31
31
  0,
32
32
  componentInfo.path.lastIndexOf(pathSymbol),
@@ -118,3 +118,5 @@ module.exports = (name, option = {}) => {
118
118
  });
119
119
  });
120
120
  };
121
+
122
+ module.exports.getBuildEntrys = getBuildEntrys;
@@ -187,6 +187,36 @@ module.exports = function (content, map, meta) {
187
187
  callback(error);
188
188
  return true;
189
189
  }
190
+ /----------- common assets start -------------/
191
+ let commonAssets;
192
+ try {
193
+ let dataJsonFile = fs.existsSync(
194
+ path.join(configPath, name + '.common.assets.json'),
195
+ );
196
+
197
+ if (dataJsonFile) {
198
+ commonAssets = JSON.parse(
199
+ fs.readFileSync(
200
+ path.resolve(configPath, name + '.common.assets.json'),
201
+ { encoding: 'utf8' },
202
+ ),
203
+ );
204
+ } else {
205
+ delete require.cache[
206
+ require.resolve(path.resolve(configPath, name + '.common.assets.js'))
207
+ ];
208
+ commonAssets = require(path.resolve(
209
+ configPath,
210
+ name + '.common.assets.js',
211
+ )).default;
212
+ }
213
+ } catch (error) {
214
+ // 公共资源配置非必填,若不存在可跳过
215
+ // error.message += ` in ${configPath}${name}.common.assets.json or ${configPath}${name}.common.assets.js`;
216
+ // callback(error);
217
+ }
218
+ /----------- common assets end -------------/
219
+
190
220
 
191
221
  if (names.has(config.base.module_name)) {
192
222
  callback(
@@ -201,6 +231,7 @@ module.exports = function (content, map, meta) {
201
231
  if (name === 'main') {
202
232
  main.config = config;
203
233
  main.data = data;
234
+ main.commonAssets = commonAssets;
204
235
  return;
205
236
  }
206
237
  const id = Math.random().toString(16).slice(2);
@@ -344,6 +375,10 @@ module.exports = function (content, map, meta) {
344
375
  };
345
376
  mainConfig.configuration.unshift(chart);
346
377
  }
378
+ // 公共资源配置
379
+ if (main.commonAssets && Array.isArray(main.commonAssets)) {
380
+ mainConfig.commonAssets = main.commonAssets
381
+ }
347
382
 
348
383
  // 子组件排序,有配置项则以chilren排序,否则以文件顺序排序
349
384
  if (mainConfig.children) {
@@ -407,6 +442,9 @@ module.exports = function (content, map, meta) {
407
442
  delete mainConfig.presetChildren;
408
443
  }
409
444
 
445
+ console.log(
446
+ JSON.stringify(mainConfig)
447
+ )
410
448
  file += '\n';
411
449
  file += `${vname}.getDefaultConfig=function(){return ${JSON.stringify(
412
450
  mainConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/react-component-builder",
3
- "version": "0.19.4",
3
+ "version": "0.19.5-beta.1",
4
4
  "files": [
5
5
  "launcher",
6
6
  "templates",
@@ -73,4 +73,4 @@
73
73
  "publishConfig": {
74
74
  "registry": "https://registry.npmjs.org/"
75
75
  }
76
- }
76
+ }