@opennextjs/cloudflare 1.0.0 → 1.0.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.
@@ -49,10 +49,15 @@ export function getCacheAssets(opts) {
49
49
  }
50
50
  return assets;
51
51
  }
52
+ async function getPlatformProxyEnv(options, key) {
53
+ const proxy = await getPlatformProxy(options);
54
+ const prefix = proxy.env[key];
55
+ await proxy.dispose();
56
+ return prefix;
57
+ }
52
58
  async function populateR2IncrementalCache(options, populateCacheOptions) {
53
59
  logger.info("\nPopulating R2 incremental cache...");
54
60
  const config = unstable_readConfig({ env: populateCacheOptions.environment });
55
- const proxy = await getPlatformProxy(populateCacheOptions);
56
61
  const binding = config.r2_buckets.find(({ binding }) => binding === R2_CACHE_BINDING_NAME);
57
62
  if (!binding) {
58
63
  throw new Error(`No R2 binding ${JSON.stringify(R2_CACHE_BINDING_NAME)} found!`);
@@ -61,10 +66,11 @@ async function populateR2IncrementalCache(options, populateCacheOptions) {
61
66
  if (!bucket) {
62
67
  throw new Error(`R2 binding ${JSON.stringify(R2_CACHE_BINDING_NAME)} should have a 'bucket_name'`);
63
68
  }
69
+ const prefix = await getPlatformProxyEnv(populateCacheOptions, R2_CACHE_PREFIX_ENV_NAME);
64
70
  const assets = getCacheAssets(options);
65
71
  for (const { fullPath, key, buildId, isFetch } of tqdm(assets)) {
66
72
  const cacheKey = computeCacheKey(key, {
67
- prefix: proxy.env[R2_CACHE_PREFIX_ENV_NAME],
73
+ prefix,
68
74
  buildId,
69
75
  cacheType: isFetch ? "fetch" : "cache",
70
76
  });
@@ -78,11 +84,11 @@ async function populateR2IncrementalCache(options, populateCacheOptions) {
78
84
  async function populateKVIncrementalCache(options, populateCacheOptions) {
79
85
  logger.info("\nPopulating KV incremental cache...");
80
86
  const config = unstable_readConfig({ env: populateCacheOptions.environment });
81
- const proxy = await getPlatformProxy(populateCacheOptions);
82
87
  const binding = config.kv_namespaces.find(({ binding }) => binding === KV_CACHE_BINDING_NAME);
83
88
  if (!binding) {
84
89
  throw new Error(`No KV binding ${JSON.stringify(KV_CACHE_BINDING_NAME)} found!`);
85
90
  }
91
+ const prefix = await getPlatformProxyEnv(populateCacheOptions, KV_CACHE_PREFIX_ENV_NAME);
86
92
  const assets = getCacheAssets(options);
87
93
  const chunkSize = Math.max(1, populateCacheOptions.cacheChunkSize ?? 25);
88
94
  const totalChunks = Math.ceil(assets.length / chunkSize);
@@ -93,7 +99,7 @@ async function populateKVIncrementalCache(options, populateCacheOptions) {
93
99
  .slice(i * chunkSize, (i + 1) * chunkSize)
94
100
  .map(({ fullPath, key, buildId, isFetch }) => ({
95
101
  key: computeCacheKey(key, {
96
- prefix: proxy.env[KV_CACHE_PREFIX_ENV_NAME],
102
+ prefix,
97
103
  buildId,
98
104
  cacheType: isFetch ? "fetch" : "cache",
99
105
  }),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opennextjs/cloudflare",
3
3
  "description": "Cloudflare builder for next apps",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "opennextjs-cloudflare": "dist/cli/index.js"