@valbuild/server 0.60.19 → 0.60.21

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.
@@ -2597,6 +2597,7 @@ class RemoteFS {
2597
2597
  // TODO: a Map would be better here
2598
2598
 
2599
2599
  class ProxyValServer extends ValServer {
2600
+ moduleCache = {};
2600
2601
  constructor(cwd, options, apiOptions, callbacks) {
2601
2602
  const remoteFS = new RemoteFS();
2602
2603
  super(cwd, remoteFS, options, callbacks);
@@ -2610,10 +2611,17 @@ class ProxyValServer extends ValServer {
2610
2611
  /** Remote FS dependent methods: */
2611
2612
 
2612
2613
  async getModule(moduleId, options) {
2614
+ const cacheKey = moduleId + ";" + JSON.stringify(options) + this.options.git.commit + this.cwd;
2615
+ const cachedModule = this.moduleCache[cacheKey];
2616
+ if (cachedModule) {
2617
+ return Promise.resolve(cachedModule);
2618
+ }
2613
2619
  if (!this.lazyService) {
2614
2620
  this.lazyService = await createService(this.cwd, this.apiOptions, this.remoteFS);
2615
2621
  }
2616
- return this.lazyService.get(moduleId, "", options);
2622
+ const currentModule = await this.lazyService.get(moduleId, "", options);
2623
+ this.moduleCache[cacheKey] = currentModule;
2624
+ return currentModule;
2617
2625
  }
2618
2626
  execCommit(patches, cookies) {
2619
2627
  return withAuth(this.options.valSecret, cookies, "execCommit", async ({
@@ -2597,6 +2597,7 @@ class RemoteFS {
2597
2597
  // TODO: a Map would be better here
2598
2598
 
2599
2599
  class ProxyValServer extends ValServer {
2600
+ moduleCache = {};
2600
2601
  constructor(cwd, options, apiOptions, callbacks) {
2601
2602
  const remoteFS = new RemoteFS();
2602
2603
  super(cwd, remoteFS, options, callbacks);
@@ -2610,10 +2611,17 @@ class ProxyValServer extends ValServer {
2610
2611
  /** Remote FS dependent methods: */
2611
2612
 
2612
2613
  async getModule(moduleId, options) {
2614
+ const cacheKey = moduleId + ";" + JSON.stringify(options) + this.options.git.commit + this.cwd;
2615
+ const cachedModule = this.moduleCache[cacheKey];
2616
+ if (cachedModule) {
2617
+ return Promise.resolve(cachedModule);
2618
+ }
2613
2619
  if (!this.lazyService) {
2614
2620
  this.lazyService = await createService(this.cwd, this.apiOptions, this.remoteFS);
2615
2621
  }
2616
- return this.lazyService.get(moduleId, "", options);
2622
+ const currentModule = await this.lazyService.get(moduleId, "", options);
2623
+ this.moduleCache[cacheKey] = currentModule;
2624
+ return currentModule;
2617
2625
  }
2618
2626
  execCommit(patches, cookies) {
2619
2627
  return withAuth(this.options.valSecret, cookies, "execCommit", async ({
@@ -2566,6 +2566,7 @@ class RemoteFS {
2566
2566
  // TODO: a Map would be better here
2567
2567
 
2568
2568
  class ProxyValServer extends ValServer {
2569
+ moduleCache = {};
2569
2570
  constructor(cwd, options, apiOptions, callbacks) {
2570
2571
  const remoteFS = new RemoteFS();
2571
2572
  super(cwd, remoteFS, options, callbacks);
@@ -2579,10 +2580,17 @@ class ProxyValServer extends ValServer {
2579
2580
  /** Remote FS dependent methods: */
2580
2581
 
2581
2582
  async getModule(moduleId, options) {
2583
+ const cacheKey = moduleId + ";" + JSON.stringify(options) + this.options.git.commit + this.cwd;
2584
+ const cachedModule = this.moduleCache[cacheKey];
2585
+ if (cachedModule) {
2586
+ return Promise.resolve(cachedModule);
2587
+ }
2582
2588
  if (!this.lazyService) {
2583
2589
  this.lazyService = await createService(this.cwd, this.apiOptions, this.remoteFS);
2584
2590
  }
2585
- return this.lazyService.get(moduleId, "", options);
2591
+ const currentModule = await this.lazyService.get(moduleId, "", options);
2592
+ this.moduleCache[cacheKey] = currentModule;
2593
+ return currentModule;
2586
2594
  }
2587
2595
  execCommit(patches, cookies) {
2588
2596
  return withAuth(this.options.valSecret, cookies, "execCommit", async ({
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "types": "dist/valbuild-server.cjs.d.ts",
15
- "version": "0.60.19",
15
+ "version": "0.60.21",
16
16
  "scripts": {
17
17
  "typecheck": "tsc --noEmit",
18
18
  "test": "jest",
@@ -24,9 +24,9 @@
24
24
  "concurrently": "^7.6.0"
25
25
  },
26
26
  "dependencies": {
27
- "@valbuild/core": "~0.60.19",
28
- "@valbuild/shared": "~0.60.19",
29
- "@valbuild/ui": "~0.60.19",
27
+ "@valbuild/core": "~0.60.21",
28
+ "@valbuild/shared": "~0.60.21",
29
+ "@valbuild/ui": "~0.60.21",
30
30
  "express": "^4.18.2",
31
31
  "image-size": "^1.0.2",
32
32
  "minimatch": "^3.0.4",