@next-core/brick-container 3.0.4 → 3.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/brick-container",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Brick Container Server",
5
5
  "homepage": "https://github.com/easyops-cn/next-core/tree/master/packages/brick-container",
6
6
  "license": "GPL-3.0",
@@ -53,5 +53,5 @@
53
53
  "@next-core/runtime": "*",
54
54
  "@next-core/utils": "*"
55
55
  },
56
- "gitHead": "097599e1a69e217a15fe69710ab37c15fead7843"
56
+ "gitHead": "c8c26e68769238b17ef6f7e11f7c188a184a41cb"
57
57
  }
package/serve/getProxy.js CHANGED
@@ -4,6 +4,7 @@ import { getBrickPackages } from "@next-core/serve-helpers";
4
4
  import { getStoryboards } from "./utils/getStoryboards.js";
5
5
  import { fixV2Storyboard } from "./utils/fixV2Storyboard.js";
6
6
  import { injectIndexHtml } from "./utils/injectIndexHtml.js";
7
+ import { concatBrickPackages } from "./utils/concatBrickPackages.js";
7
8
 
8
9
  export default function getProxy(env, getRawIndexHtml) {
9
10
  const { rootDir, localMicroApps, baseHref, useRemote, useLocalContainer } =
@@ -37,7 +38,10 @@ export default function getProxy(env, getRawIndexHtml) {
37
38
 
38
39
  // Todo: filter out local micro-apps and brick packages
39
40
  data.storyboards = storyboards.concat(data.storyboards);
40
- data.brickPackages = brickPackages.concat(data.brickPackages);
41
+ data.brickPackages = concatBrickPackages(
42
+ brickPackages,
43
+ data.brickPackages
44
+ );
41
45
  removeCacheHeaders(res);
42
46
  return JSON.stringify(result);
43
47
  }
@@ -171,9 +175,10 @@ export default function getProxy(env, getRawIndexHtml) {
171
175
  ) {
172
176
  const content = responseBuffer.toString("utf-8");
173
177
  const result = JSON.parse(content);
174
- result.brickPackages = (
175
- await getBrickPackages(rootDir, true)
176
- ).concat(result.brickPackages);
178
+ result.brickPackages = concatBrickPackages(
179
+ await getBrickPackages(rootDir, true),
180
+ result.brickPackages
181
+ );
177
182
  delete result.templatePackages;
178
183
  removeCacheHeaders(res);
179
184
  return JSON.stringify(result);
@@ -0,0 +1,11 @@
1
+ export function concatBrickPackages(localPackages, remotePackages) {
2
+ const localIds = new Set();
3
+ for (const pkg of localPackages) {
4
+ localIds.add(pkg.id ?? pkg.filePath.split("/", 2).join("/"));
5
+ }
6
+ return localPackages.concat(
7
+ remotePackages.filter(
8
+ (pkg) => !localIds.has(pkg.id ?? pkg.filePath.split("/", 2).join("/"))
9
+ )
10
+ );
11
+ }