Skip to content

Commit 3342a08

Browse files
authored
Merge pull request #2132 from contentstack/enh/DX-3560
chore(setup): use In-Memory Config During Prepack
2 parents 2af1312 + b18e330 commit 3342a08

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-utilities/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-utilities",
3-
"version": "1.14.2",
3+
"version": "1.14.3",
44
"description": "Utilities for contentstack projects",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

packages/contentstack-utilities/src/config-handler.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ const cwd = process.env.CS_CLI_CONFIG_PATH;
2323

2424
class Config {
2525
private config: Conf;
26+
private inMemoryStore: Map<string, any> = new Map();
27+
private isPrepackMode: boolean;
2628

2729
constructor() {
30+
this.isPrepackMode = process.env.NODE_ENV === 'PREPACK_MODE';
2831
this.init();
29-
this.importOldConfig();
32+
if (!this.isPrepackMode) {
33+
this.importOldConfig();
34+
}
3035
}
3136

3237
init() {
38+
// Skip file-based config during prepack to prevent race conditions
39+
if (this.isPrepackMode) {
40+
// Initialize with empty in-memory store for prepack
41+
return;
42+
}
3343
return ENCRYPT_CONF === true ? this.getEncryptedConfig() : this.getDecryptedConfig();
3444
}
3545

@@ -204,20 +214,35 @@ class Config {
204214
}
205215

206216
get(key): string | any {
217+
if (this.isPrepackMode) {
218+
return this.inMemoryStore.get(key);
219+
}
207220
return this.config?.get(key);
208221
}
209222

210223
set(key, value) {
224+
if (this.isPrepackMode) {
225+
this.inMemoryStore.set(key, value);
226+
return this;
227+
}
211228
this.config?.set(key, value);
212229
return this.config;
213230
}
214231

215232
delete(key) {
233+
if (this.isPrepackMode) {
234+
this.inMemoryStore.delete(key);
235+
return this;
236+
}
216237
this.config?.delete(key);
217238
return this.config;
218239
}
219240

220241
clear() {
242+
if (this.isPrepackMode) {
243+
this.inMemoryStore.clear();
244+
return;
245+
}
221246
this.config?.clear();
222247
}
223248
}

packages/contentstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@contentstack/cli-config": "~1.15.2",
3939
"@contentstack/cli-launch": "^1.9.2",
4040
"@contentstack/cli-migration": "~1.8.1",
41-
"@contentstack/cli-utilities": "~1.14.2",
41+
"@contentstack/cli-utilities": "~1.14.3",
4242
"@contentstack/cli-variants": "~1.3.1",
4343
"@contentstack/management": "~1.22.0",
4444
"@oclif/core": "^4.3.0",

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)