@hyext/builder-revues 1.2.1-alpha.0 → 1.2.2-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/index.js +32 -10
  2. package/package.json +8 -5
package/dist/index.js CHANGED
@@ -559,11 +559,16 @@ function render(content, data, opts) {
559
559
  });
560
560
  return temp(data, opts);
561
561
  }
562
+ const cache = {};
562
563
  function renderTemplate(input, output, data) {
563
- const content = fs__default["default"]
564
- .readFileSync(input)
565
- .toString();
566
- fs__default["default"].outputFileSync(output, render(content, data));
564
+ let renderResult = cache[input];
565
+ if (!renderResult) {
566
+ const templ = fs__default["default"]
567
+ .readFileSync(input)
568
+ .toString();
569
+ renderResult = render(templ, data);
570
+ }
571
+ fs__default["default"].outputFileSync(output, renderResult);
567
572
  }
568
573
 
569
574
  function objectToParamsStr(obj) {
@@ -705,7 +710,7 @@ function genEntrys(props) {
705
710
  });
706
711
  }
707
712
 
708
- const libVersion = "1.0.1" ;
713
+ const libVersion = "1.0.2" ;
709
714
  const libCdn = '//a.msstatic.com/huya/hd/h5/static-source/revue/lib';
710
715
 
711
716
  function getLibVersion(builderConfig) {
@@ -717,7 +722,7 @@ function getCdnLibUrl(version) {
717
722
  function isLibDevVerion(builderConfig) {
718
723
  return getLibVersion(builderConfig) === 'dev';
719
724
  }
720
- function getLibUrl(builderConfig, localPath) {
725
+ function getLibUrl(builderConfig, localPath, check = true) {
721
726
  return __awaiter(this, void 0, void 0, function* () {
722
727
  const version = getLibVersion(builderConfig);
723
728
  if (version == null) {
@@ -727,7 +732,7 @@ function getLibUrl(builderConfig, localPath) {
727
732
  return localPath;
728
733
  }
729
734
  const res = getCdnLibUrl(version);
730
- yield checkCdnSourceExist(res);
735
+ check && (yield checkCdnSourceExist(res));
731
736
  return res;
732
737
  });
733
738
  }
@@ -877,7 +882,12 @@ function mergeMiniprogramPackage(releasePath, opts) {
877
882
  }
878
883
  function renderMiniProgram(opts) {
879
884
  return __awaiter(this, void 0, void 0, function* () {
880
- yield renderMiniprogramTemplate(opts);
885
+ return yield renderMiniprogramTemplate(opts);
886
+ });
887
+ }
888
+ function rerenderHTML(opts) {
889
+ opts.htmlRenderConfigList.forEach(config => {
890
+ renderTemplate(config.input, config.output, config.data);
881
891
  });
882
892
  }
883
893
  function renderMiniprogramTemplate(opts) {
@@ -886,7 +896,7 @@ function renderMiniprogramTemplate(opts) {
886
896
  const extConfig = getPackageExtConfig(packagePath);
887
897
  const sourcePathPrefix = yield getLibUrl(builderConfig, path__default["default"].relative(mainPath, releasePath));
888
898
  const packageExtConfigStr = JSON.stringify(extConfig);
889
- const renderConfigList = [
899
+ const htmlRenderConfigList = [
890
900
  {
891
901
  input: path__default["default"].join(mainPath, 'view.html'),
892
902
  output: path__default["default"].join(mainPath, 'view.html'),
@@ -902,6 +912,9 @@ function renderMiniprogramTemplate(opts) {
902
912
  }
903
913
  }
904
914
  ];
915
+ const renderConfigList = [
916
+ ...htmlRenderConfigList
917
+ ];
905
918
  if (dev) {
906
919
  renderConfigList.push({
907
920
  input: path__default["default"].join(templatePath, 'remote-debugger.hbs'),
@@ -933,6 +946,9 @@ function renderMiniprogramTemplate(opts) {
933
946
  entryRenderConfList.concat(renderConfigList).forEach(config => {
934
947
  renderTemplate(config.input, config.output, config.data);
935
948
  });
949
+ return {
950
+ htmlRenderConfigList
951
+ };
936
952
  });
937
953
  }
938
954
 
@@ -948,6 +964,7 @@ function mergePackages(projectConfig, outputPath, opts) {
948
964
  dev: opts.dev,
949
965
  builderConfig: opts.builderConfig
950
966
  };
967
+ let renderResult;
951
968
  const implement = (watch) => __awaiter(this, void 0, void 0, function* () {
952
969
  logger.log('正在合并分包...');
953
970
  let mergeResult;
@@ -960,7 +977,12 @@ function mergePackages(projectConfig, outputPath, opts) {
960
977
  }
961
978
  else {
962
979
  mergeResult = mergeMiniprogramPackage(outputPath, opts);
963
- !watch && (yield renderMiniProgram(Object.assign(Object.assign({}, baseRenderOpts), mergeResult)));
980
+ if (!watch) {
981
+ renderResult = yield renderMiniProgram(Object.assign(Object.assign({}, baseRenderOpts), mergeResult));
982
+ }
983
+ else if (renderResult != null) {
984
+ rerenderHTML(renderResult);
985
+ }
964
986
  }
965
987
  logger.success('合并分包完成');
966
988
  return mergeResult;
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@hyext/builder-revues",
3
- "version": "1.2.1-alpha.0",
3
+ "version": "1.2.2-alpha.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "loler",
6
6
  "homepage": "",
7
7
  "license": "ISC",
8
8
  "main": "dist",
9
+ "scripts": {
10
+ "minify": "node scripts/minify"
11
+ },
9
12
  "directories": {
10
13
  "src": "src"
11
14
  },
@@ -21,9 +24,9 @@
21
24
  "url": "https://git.huya.com/exc/web/revue.git"
22
25
  },
23
26
  "dependencies": {
24
- "@revues/cocos-web-adapter": "1.2.1-alpha.0",
25
- "@revues/code-compiler": "1.2.1-alpha.0",
26
- "@revues/web-sdk-core": "1.2.1-alpha.0",
27
+ "@revues/cocos-web-adapter": "1.2.2-alpha.0",
28
+ "@revues/code-compiler": "1.2.2-alpha.0",
29
+ "@revues/web-sdk-core": "1.2.2-alpha.0",
27
30
  "archiver": "^7.0.1",
28
31
  "axios": "^1.7.3",
29
32
  "chalk": "^2.4.2",
@@ -43,5 +46,5 @@
43
46
  "@types/ramda": "^0.29.11",
44
47
  "terser": "^5.31.0"
45
48
  },
46
- "gitHead": "44dff694d724a7f755ce7274d4dc763d72994b15"
49
+ "gitHead": "549d13206b92455292f048038d65c73260f17e35"
47
50
  }