@graphcommerce/next-config 10.0.0 → 10.0.1-canary.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.0.1-canary.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2571](https://github.com/graphcommerce-org/graphcommerce/pull/2571) [`a16bed1`](https://github.com/graphcommerce-org/graphcommerce/commit/a16bed1b8670932e273d5ea7114bf01fda40f2f8) - Always copy the file if the original file is a core file, allowing overrides. ([@paales](https://github.com/paales))
8
+
9
+ ## 10.0.1-canary.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [#2568](https://github.com/graphcommerce-org/graphcommerce/pull/2568) [`64d843e`](https://github.com/graphcommerce-org/graphcommerce/commit/64d843e4b98edbc2779ae75930d657dd7c7fdda2) - "No graphcommerce.config.js found in the project, using demo config" should have referenced 'graphcommerce.config.ts' ([@paales](https://github.com/paales))
14
+
3
15
  ## 10.0.0
4
16
 
5
17
  ### Major Changes
@@ -110,274 +122,6 @@
110
122
 
111
123
  - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`5ffa0ee`](https://github.com/graphcommerce-org/graphcommerce/commit/5ffa0ee1d620f4f1c38bc5df36cbd527bcc43cf9) - Migrated `@graphcommerce/next-config` package to `"type": "module"` ([@paales](https://github.com/paales))
112
124
 
113
- ## 10.0.0-canary.72
114
-
115
- ## 10.0.0-canary.71
116
-
117
- ## 10.0.0-canary.70
118
-
119
- ### Major Changes
120
-
121
- - [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
122
-
123
- ### Minor Changes
124
-
125
- - [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`ea75841`](https://github.com/graphcommerce-org/graphcommerce/commit/ea758413b1ee8b8f2584e8f4135cb582fb87445f) - Migrated to vitest ([@paales](https://github.com/paales))
126
-
127
- ## 10.0.0-canary.69
128
-
129
- ## 10.0.0-canary.68
130
-
131
- ## 10.0.0-canary.67
132
-
133
- ## 10.0.0-canary.66
134
-
135
- ## 10.0.0-canary.65
136
-
137
- ## 10.0.0-canary.64
138
-
139
- ## 10.0.0-canary.63
140
-
141
- ## 10.0.0-canary.62
142
-
143
- ## 10.0.0-canary.61
144
-
145
- ## 10.0.0-canary.60
146
-
147
- ## 10.0.0-canary.59
148
-
149
- ## 10.0.0-canary.58
150
-
151
- ## 10.0.0-canary.57
152
-
153
- ## 10.0.0-canary.56
154
-
155
- ### Major Changes
156
-
157
- - [#2546](https://github.com/graphcommerce-org/graphcommerce/pull/2546) [`ed9332a`](https://github.com/graphcommerce-org/graphcommerce/commit/ed9332a7f78966d932041d9a7725641edc92b28d) - ## GraphCommerce 10 - Turbopack Support
158
-
159
- This major release brings full Turbopack compatibility, dramatically improving development speed.
160
-
161
- ### 🚀 Turbopack-Compatible Interceptor System
162
-
163
- The entire plugin/interceptor system has been rewritten to work with Turbopack:
164
-
165
- - **No more Webpack plugins** - Removed `InterceptorPlugin` webpack plugin entirely
166
- - **File-based interception** - Original files are moved to `.original.tsx` and replaced with interceptor content
167
- - **Direct imports** - Interceptors import from `.original` files instead of embedding source
168
- - **New CLI commands**:
169
- - `graphcommerce codegen-interceptors` - Generate interceptor files
170
- - `graphcommerce cleanup-interceptors` - Reset interceptor system, restore original files
171
- - **Stable file hashing** - Deterministic interceptor generation for better caching
172
-
173
- ### ⚙️ Treeshakable Configuration System
174
-
175
- Replaced Webpack `DefinePlugin`-based `import.meta.graphCommerce` with a new generated configuration system:
176
-
177
- - **New `codegen-config-values` command** - Generates TypeScript files with precise typing
178
- - **Schema-driven** - Dynamically introspects Zod schemas to determine all available properties
179
- - **Fully treeshakable** - Unused config values are eliminated from the bundle
180
- - **Type-safe** - Uses `Get<GraphCommerceConfig, 'path'>` for nested property access
181
- - **Separate files for nested objects** - Optimal treeshaking for complex configurations
182
-
183
- ### 🔧 withGraphCommerce Changes
184
-
185
- - **Removed** `InterceptorPlugin` - No longer needed with file-based interception
186
- - **Removed** `DefinePlugin` for `import.meta.graphCommerce` - Replaced with generated config
187
- - **Removed** `@mui/*` alias rewrites - No longer required
188
- - **Added** Turbopack loader rules for `.yaml`, `.yml`, and `.po` files
189
- - **Added** `serverExternalPackages` for all `@whatwg-node/*` packages
190
- - **Added** `optimizePackageImports` for better bundle optimization
191
- - **Added** `images.qualities: [52, 75]` for Next.js image optimization
192
-
193
- ### 📦 Lingui Configuration
194
-
195
- - **Renamed** `lingui.config.js` → `lingui.config.ts` with TypeScript support
196
- - **Updated** `@graphcommerce/lingui-next/config` to TypeScript with proper exports
197
- - **Simplified** formatter options
198
-
199
- ### ⚛️ React 19 & Next.js 16 Compatibility
200
-
201
- - Updated `RefObject<T>` types for React 19 (now includes `null` by default)
202
- - Replaced deprecated `React.VFC` with `React.FC`
203
- - Fixed `useRef` calls to require explicit initial values
204
- - Updated `MutableRefObject` usage in `framer-scroller`
205
-
206
- ### 📋 ESLint 9 Flat Config
207
-
208
- - Migrated from legacy `.eslintrc` to new flat config format (`eslint.config.mjs`)
209
- - Updated `@typescript-eslint/*` packages to v8
210
- - Fixed AST selector for `SxProps` rule (`typeParameters` → `typeArguments`)
211
-
212
- ### 🔄 Apollo Client
213
-
214
- - Fixed deprecated `name` option → `clientAwareness: { name: 'ssr' }`
215
- - Updated error handling types to accept `ApolloError | null | undefined`
216
-
217
- ### ⚠️ Breaking Changes
218
-
219
- - **Node.js 24.x not supported** - Restricted to `>=20 <24.0.0` due to [nodejs/undici#4290](https://github.com/nodejs/undici/issues/4290)
220
- - **Interceptor files changed** - Original components now at `.original.tsx`
221
- - **Config access changed** - Use generated config values instead of `import.meta.graphCommerce`
222
- - **ESLint config format** - Must use flat config (`eslint.config.mjs`)
223
- - **Lingui config** - Rename `lingui.config.js` to `lingui.config.ts`
224
-
225
- ### 🗑️ Removed
226
-
227
- - `InterceptorPlugin` webpack plugin
228
- - `configToImportMeta` utility
229
- - Webpack `DefinePlugin` usage for config
230
- - `@mui/*` modern alias rewrites
231
- - Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
232
-
233
- ## 9.1.0-canary.55
234
-
235
- ## 9.1.0-canary.54
236
-
237
- ## 9.1.0-canary.53
238
-
239
- ## 9.1.0-canary.52
240
-
241
- ## 9.1.0-canary.51
242
-
243
- ### Patch Changes
244
-
245
- - [#2537](https://github.com/graphcommerce-org/graphcommerce/pull/2537) [`6492d81`](https://github.com/graphcommerce-org/graphcommerce/commit/6492d819a858ffdc01a97e6914053e9cc14c8fc5) - Reduce exported scope of config so we dont introduce a hidden dependency on Magento ([@paales](https://github.com/paales))
246
-
247
- ## 9.1.0-canary.50
248
-
249
- ## 9.1.0-canary.49
250
-
251
- ## 9.1.0-canary.48
252
-
253
- ## 9.1.0-canary.47
254
-
255
- ## 9.1.0-canary.46
256
-
257
- ### Patch Changes
258
-
259
- - [`f6b9c0d`](https://github.com/graphcommerce-org/graphcommerce/commit/f6b9c0d2bc5f678fc6cde279f1590b30ef631f8a) - Temporarily pin prettier to 3.5.3 to fix the GraphCommerce build: https://github.com/hosseinmd/prettier-plugin-jsdoc/pull/246/files ([@paales](https://github.com/paales))
260
-
261
- ## 9.1.0-canary.45
262
-
263
- ### Patch Changes
264
-
265
- - [`f508396`](https://github.com/graphcommerce-org/graphcommerce/commit/f50839619c75c8f7b1782c079f1c25998cb9217b) - Solve issue where optional chaining for import.meta.graphCommmerce configuration paths didn't work. ([@paales](https://github.com/paales))
266
-
267
- ## 9.1.0-canary.44
268
-
269
- ## 9.1.0-canary.43
270
-
271
- ## 9.1.0-canary.42
272
-
273
- ## 9.1.0-canary.41
274
-
275
- ## 9.1.0-canary.40
276
-
277
- ## 9.1.0-canary.39
278
-
279
- ## 9.1.0-canary.38
280
-
281
- ## 9.1.0-canary.37
282
-
283
- ## 9.1.0-canary.36
284
-
285
- ## 9.1.0-canary.35
286
-
287
- ## 9.1.0-canary.34
288
-
289
- ## 9.1.0-canary.33
290
-
291
- ## 9.1.0-canary.32
292
-
293
- ## 9.1.0-canary.31
294
-
295
- ## 9.1.0-canary.30
296
-
297
- ## 9.1.0-canary.29
298
-
299
- ## 9.1.0-canary.28
300
-
301
- ## 9.1.0-canary.27
302
-
303
- ## 9.1.0-canary.26
304
-
305
- ## 9.1.0-canary.25
306
-
307
- ## 9.1.0-canary.24
308
-
309
- ## 9.1.0-canary.23
310
-
311
- ## 9.1.0-canary.22
312
-
313
- ## 9.1.0-canary.21
314
-
315
- ## 9.1.0-canary.20
316
-
317
- ## 9.1.0-canary.19
318
-
319
- ### Patch Changes
320
-
321
- - [#2499](https://github.com/graphcommerce-org/graphcommerce/pull/2499) [`9cf0450`](https://github.com/graphcommerce-org/graphcommerce/commit/9cf0450a41c4c74292b96f5795c7428f9d6a930c) - Remove the 'ignored' string when loading the graphcommerce config env variable loading, as that isn't always correct ([@paales](https://github.com/paales))
322
-
323
- ## 9.1.0-canary.18
324
-
325
- ### Patch Changes
326
-
327
- - [`62b71d5`](https://github.com/graphcommerce-org/graphcommerce/commit/62b71d5ed1d482fdb5b76dc19ac4d55fc41fb191) - Solve issue: TypeError: InMemoryLRUCache is not a constructor ([@paales](https://github.com/paales))
328
-
329
- ## 9.1.0-canary.17
330
-
331
- ## 9.1.0-canary.16
332
-
333
- ## 9.1.0-canary.15
334
-
335
- ## 9.0.4-canary.14
336
-
337
- ## 9.0.4-canary.13
338
-
339
- ## 9.0.4-canary.12
340
-
341
- ## 9.0.4-canary.11
342
-
343
- ## 9.0.4-canary.10
344
-
345
- ### Patch Changes
346
-
347
- - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`8b25322`](https://github.com/graphcommerce-org/graphcommerce/commit/8b253224997b59ac74d72813214dfc224f526c0a) - When a dependency is optional or has peerDependenciesMeta set to optional, make sure it doesn't crash when it is not found when calling resolveDependenciesSync ([@paales](https://github.com/paales))
348
-
349
- - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`2c79a4c`](https://github.com/graphcommerce-org/graphcommerce/commit/2c79a4cba2779bc367104ebb13e6c0d6feb6574f) - Remove redirects for `/product/$type/[url]` routes, those haven't been used for years anymore. ([@paales](https://github.com/paales))
350
-
351
- - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`30b7356`](https://github.com/graphcommerce-org/graphcommerce/commit/30b7356790efbac0f0017ef61cb1619b920100ab) - Solve issue where withGraphCommerce had a hard dependency on Magento specific configurations ([@paales](https://github.com/paales))
352
-
353
- - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`9825f59`](https://github.com/graphcommerce-org/graphcommerce/commit/9825f59b8626c315e6092950faceeab4311a5424) - Remove rewriteLegacyEnv as that hasn't been used for years ([@paales](https://github.com/paales))
354
-
355
- - [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`5ffa0ee`](https://github.com/graphcommerce-org/graphcommerce/commit/5ffa0ee1d620f4f1c38bc5df36cbd527bcc43cf9) - Migrated `@graphcommerce/next-config` package to `"type": "module"` ([@paales](https://github.com/paales))
356
-
357
- ## 9.0.4-canary.9
358
-
359
- ## 9.0.4-canary.8
360
-
361
- ## 9.0.4-canary.7
362
-
363
- ## 9.0.4-canary.6
364
-
365
- ## 9.0.4-canary.5
366
-
367
- ## 9.0.4-canary.4
368
-
369
- ## 9.0.4-canary.3
370
-
371
- ## 9.0.4-canary.2
372
-
373
- ## 9.0.4-canary.1
374
-
375
- ## 9.0.4-canary.0
376
-
377
- ### Patch Changes
378
-
379
- - [#2472](https://github.com/graphcommerce-org/graphcommerce/pull/2472) [`905157b`](https://github.com/graphcommerce-org/graphcommerce/commit/905157bec2c9e1dcf51b6e6f7b6913aa9be7b609) - Solve issue with chalk compilation because we’re not migrated to esm modules. ([@paales](https://github.com/paales))
380
-
381
125
  ## 9.0.0
382
126
 
383
127
  ### Major Changes
@@ -16,6 +16,7 @@ vi.mock('fs/promises', () => ({
16
16
  stat: vi.fn(),
17
17
  unlink: vi.fn(),
18
18
  rmdir: vi.fn(),
19
+ rename: vi.fn(),
19
20
  },
20
21
  readFile: vi.fn(),
21
22
  writeFile: vi.fn(),
@@ -24,6 +25,7 @@ vi.mock('fs/promises', () => ({
24
25
  stat: vi.fn(),
25
26
  unlink: vi.fn(),
26
27
  rmdir: vi.fn(),
28
+ rename: vi.fn(),
27
29
  }))
28
30
 
29
31
  // Mock fast-glob
@@ -425,11 +427,17 @@ describe('copyFiles', () => {
425
427
  }
426
428
  return Promise.reject(new Error(`ENOENT: no such file or directory, open '${filePath}'`))
427
429
  })
430
+ mockFs.rename.mockResolvedValue(undefined)
428
431
 
429
432
  await copyFiles()
430
433
 
434
+ // Unmanaged files should be renamed to .original and a new managed file created
435
+ expect(mockFs.rename).toHaveBeenCalledWith(
436
+ path.join(mockCwd, 'file.ts'),
437
+ path.join(mockCwd, 'file.original.ts'),
438
+ )
431
439
  expect(consoleInfo).toHaveBeenCalledWith(
432
- expect.stringContaining('Note: File file.ts has been modified'),
440
+ expect.stringContaining('Renamed existing file to: file.original.ts'),
433
441
  )
434
442
  })
435
443
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports[`parses an env config object 1`] = `
4
4
  {
5
- "GC_DEMO_MODE": true,
6
5
  "GC_STOREFRONT": [
7
6
  {
8
7
  "defaultLocale": true,
@@ -14,10 +13,8 @@ exports[`parses an env config object 1`] = `
14
13
  },
15
14
  ],
16
15
  "GC_STOREFRONT_0_DEFAULT_LOCALE": true,
17
- "GC_STOREFRONT_0_HYGRAPH_LOCALES_0": "en",
18
16
  "GC_STOREFRONT_0_LOCALE": "en",
19
17
  "GC_STOREFRONT_0_MAGENTO_STORE_CODE": "en_us",
20
- "GC_STOREFRONT_1_HYGRAPH_LOCALES_0": "de",
21
18
  "GC_STOREFRONT_1_LOCALE": "de",
22
19
  "GC_STOREFRONT_1_MAGENTO_STORE_CODE": "de_de",
23
20
  }
@@ -557,6 +557,14 @@ it('finds plugins', () => {
557
557
  "targetModule": "@graphcommerce/magento-product-configurable",
558
558
  "type": "component",
559
559
  },
560
+ {
561
+ "enabled": true,
562
+ "sourceExport": "GraphQLProvider",
563
+ "sourceModule": "@graphcommerce/magento-recently-viewed-products/plugins/AddRecentlyViewedProductsTypePolicies",
564
+ "targetExport": "GraphQLProvider",
565
+ "targetModule": "@graphcommerce/graphql",
566
+ "type": "component",
567
+ },
560
568
  {
561
569
  "enabled": true,
562
570
  "sourceExport": "cartItemToCartItemInput",
@@ -87,7 +87,7 @@ it('it generates an interceptor', async () => {
87
87
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
88
88
  * original source changes.
89
89
  *
90
- * @see {@link file://./PaymentMethodContextProvider.tsx} for original source file
90
+ * @see {@link file://./PaymentMethodContextProvider.original.tsx} for original source file
91
91
  * @see {PluginAddBraintreeMethods} for source of applied plugin
92
92
  * @see {PluginAddMollieMethods} for source of applied plugin
93
93
  */
@@ -188,7 +188,7 @@ it('it can apply multiple plugins to a single export', async () => {
188
188
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
189
189
  * original source changes.
190
190
  *
191
- * @see {@link file://./PaymentMethodContextProvider.tsx} for original source file
191
+ * @see {@link file://./PaymentMethodContextProvider.original.tsx} for original source file
192
192
  * @see {PluginAddAdyenMethods} for source of applied plugin
193
193
  * @see {PluginAddMollieMethods} for source of applied plugin
194
194
  */
@@ -257,7 +257,7 @@ it('it handles on duplicates gracefully', async () => {
257
257
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
258
258
  * original source changes.
259
259
  *
260
- * @see {@link file://./PaymentMethodContextProvider.tsx} for original source file
260
+ * @see {@link file://./PaymentMethodContextProvider.original.tsx} for original source file
261
261
  * @see {PluginAddBraintreeMethods} for source of applied plugin
262
262
  * @see {PluginAddBraintreeMethods} for source of applied plugin
263
263
  */
@@ -434,7 +434,7 @@ it('adds debug logging to interceptors for components', async () => {
434
434
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
435
435
  * original source changes.
436
436
  *
437
- * @see {@link file://./graphqlConfig.ts} for original source file
437
+ * @see {@link file://./graphqlConfig.original.ts} for original source file
438
438
  * @see {pluginhygraphInitMemoryCache} for source of applied plugin
439
439
  * @see {pluginmagentoInitMemoryCache} for source of applied plugin
440
440
  */
@@ -1,6 +1,6 @@
1
1
  import 'cosmiconfig';
2
2
  import '../generated/config.js';
3
- export { l as loadConfig, r as replaceConfigInString } from '../loadConfig-CZYUe1jE.js';
3
+ export { l as loadConfig, r as replaceConfigInString } from '../loadConfig-DFvwanrZ.js';
4
4
  import 'zod';
5
5
  import '@apollo/client/utilities/internal';
6
6
  import 'chalk';
package/dist/index.js CHANGED
@@ -4,8 +4,8 @@ import path from 'path';
4
4
  import { glob, sync } from 'glob';
5
5
  import { findParentPath } from './utils/findParentPath.js';
6
6
  import { spawn } from 'child_process';
7
- import { l as loadConfig, t as toEnvStr } from './loadConfig-CZYUe1jE.js';
8
- export { r as replaceConfigInString } from './loadConfig-CZYUe1jE.js';
7
+ import { l as loadConfig, t as toEnvStr } from './loadConfig-DFvwanrZ.js';
8
+ export { r as replaceConfigInString } from './loadConfig-DFvwanrZ.js';
9
9
  import { parseFileSync, parseSync as parseSync$1, transformFileSync } from '@swc/core';
10
10
  import fs$1, { writeFileSync, readFileSync, existsSync, rmSync, mkdirSync } from 'fs';
11
11
  import { resolve as resolve$2 } from 'import-meta-resolve';
@@ -729,7 +729,9 @@ async function generateInterceptor(interceptor, config, oldInterceptorSource) {
729
729
  `@see {${sourceName(name(replacePlugin))}} for source of replaced component`
730
730
  );
731
731
  } else {
732
- pluginSee.push(`@see {@link file://./${targetExport}.tsx} for original source file`);
732
+ pluginSee.push(
733
+ `@see {@link file://./${targetExport}.original.tsx} for original source file`
734
+ );
733
735
  }
734
736
  const pluginInterceptors = componentPlugins.reverse().map((plugin) => {
735
737
  const pluginName = sourceName(name(plugin));
@@ -774,7 +776,9 @@ export const ${targetExport} = ${carry}`;
774
776
  `@see {${sourceName(name(replacePlugin))}} for source of replaced function`
775
777
  );
776
778
  } else {
777
- pluginSee.push(`@see {@link file://./${targetExport}.ts} for original source file`);
779
+ pluginSee.push(
780
+ `@see {@link file://./${targetExport}.original.ts} for original source file`
781
+ );
778
782
  }
779
783
  const pluginInterceptors = functionPlugins.reverse().map((plugin) => {
780
784
  const pluginName = sourceName(name(plugin));
@@ -1079,7 +1083,7 @@ async function updateGitignore(managedFiles) {
1079
1083
  try {
1080
1084
  content = await fs.readFile(gitignorePath, "utf-8");
1081
1085
  debug("Reading existing .gitignore");
1082
- } catch (err) {
1086
+ } catch {
1083
1087
  debug(".gitignore not found, creating new file");
1084
1088
  content = "";
1085
1089
  }
@@ -1114,6 +1118,11 @@ function getFileManagement(content) {
1114
1118
  if (contentStr.startsWith(MANAGED_BY_GC)) return "graphcommerce";
1115
1119
  return "unmanaged";
1116
1120
  }
1121
+ function getOriginalFilename(filePath) {
1122
+ const ext = path.extname(filePath);
1123
+ const base = filePath.slice(0, -ext.length);
1124
+ return `${base}.original${ext}`;
1125
+ }
1117
1126
  async function copyFiles() {
1118
1127
  const startTime = performance.now();
1119
1128
  debug("Starting copyFiles");
@@ -1220,11 +1229,15 @@ Path: ${copyDir}`
1220
1229
  return;
1221
1230
  }
1222
1231
  if (management === "unmanaged") {
1232
+ const originalPath = getOriginalFilename(targetPath);
1233
+ await fs.rename(targetPath, originalPath);
1234
+ const originalRelative = getOriginalFilename(file);
1223
1235
  console.info(
1224
- `Note: File ${file} has been modified. Add '${MANAGED_LOCALLY.trim()}' at the top to manage it locally.`
1236
+ `Renamed existing file to: ${originalRelative}
1237
+ Creating managed file: ${file}`
1225
1238
  );
1226
- debug(`File ${file} doesn't have management comment, skipping`);
1227
- return;
1239
+ debug(`Renamed ${file} to ${originalRelative}`);
1240
+ targetContent = void 0;
1228
1241
  }
1229
1242
  debug(`File ${file} is managed by graphcommerce, will update if needed`);
1230
1243
  } catch (err) {
@@ -284,7 +284,7 @@ function loadConfig(cwd) {
284
284
  let confFile = result?.config;
285
285
  if (!confFile) {
286
286
  if (isMainProcess)
287
- console.warn("No graphcommerce.config.js found in the project, using demo config");
287
+ console.warn("No graphcommerce.config.ts found in the project, using demo config");
288
288
  confFile = demoConfig;
289
289
  }
290
290
  confFile ||= {};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-config",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "10.0.0",
5
+ "version": "10.0.1-canary.1",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@apollo/client": "*",
66
- "@graphcommerce/prettier-config-pwa": "^10.0.0",
66
+ "@graphcommerce/prettier-config-pwa": "^10.0.1-canary.1",
67
67
  "@lingui/loader": "*",
68
68
  "@lingui/macro": "*",
69
69
  "@lingui/react": "*",
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-await-in-loop */
2
1
  import fs from 'fs/promises'
3
2
  import path from 'path'
4
3
  import fg from 'fast-glob'
@@ -38,7 +37,7 @@ async function updateGitignore(managedFiles: string[]) {
38
37
  try {
39
38
  content = await fs.readFile(gitignorePath, 'utf-8')
40
39
  debug('Reading existing .gitignore')
41
- } catch (err) {
40
+ } catch {
42
41
  debug('.gitignore not found, creating new file')
43
42
  content = ''
44
43
  }
@@ -79,6 +78,13 @@ function getFileManagement(content: Buffer | undefined): 'local' | 'graphcommerc
79
78
  return 'unmanaged'
80
79
  }
81
80
 
81
+ /** Generates the .original filename for a given file path (e.g., file.tsx -> file.original.tsx) */
82
+ function getOriginalFilename(filePath: string): string {
83
+ const ext = path.extname(filePath)
84
+ const base = filePath.slice(0, -ext.length)
85
+ return `${base}.original${ext}`
86
+ }
87
+
82
88
  /**
83
89
  * The packages are @graphcommerce/* packages and have special treatment.
84
90
  *
@@ -88,7 +94,8 @@ function getFileManagement(content: Buffer | undefined): 'local' | 'graphcommerc
88
94
  *
89
95
  * 1. If the file doesn't exist: Create directories and the file with "managed by: graphcommerce"
90
96
  * 2. If the file exists and starts with "managed by: local": Skip the file
91
- * 3. If the file exists but doesn't have a management comment: Suggest adding "managed by: local"
97
+ * 3. If the file exists but doesn't have a management comment: Rename to filename.original.ext and
98
+ * create the new managed file
92
99
  * 4. If the file is managed by graphcommerce: Update if content differs
93
100
  */
94
101
  export async function copyFiles() {
@@ -213,11 +220,15 @@ Found in packages:
213
220
  return
214
221
  }
215
222
  if (management === 'unmanaged') {
223
+ // Rename existing file to .original and create new managed file
224
+ const originalPath = getOriginalFilename(targetPath)
225
+ await fs.rename(targetPath, originalPath)
226
+ const originalRelative = getOriginalFilename(file)
216
227
  console.info(
217
- `Note: File ${file} has been modified. Add '${MANAGED_LOCALLY.trim()}' at the top to manage it locally.`,
228
+ `Renamed existing file to: ${originalRelative}\nCreating managed file: ${file}`,
218
229
  )
219
- debug(`File ${file} doesn't have management comment, skipping`)
220
- return
230
+ debug(`Renamed ${file} to ${originalRelative}`)
231
+ targetContent = undefined // Treat as new file from here
221
232
  }
222
233
 
223
234
  debug(`File ${file} is managed by graphcommerce, will update if needed`)
@@ -19,7 +19,7 @@ export function loadConfig(cwd: string): GraphCommerceConfig {
19
19
  let confFile = result?.config
20
20
  if (!confFile) {
21
21
  if (isMainProcess)
22
- console.warn('No graphcommerce.config.js found in the project, using demo config')
22
+ console.warn('No graphcommerce.config.ts found in the project, using demo config')
23
23
  confFile = demoConfig
24
24
  }
25
25
  confFile ||= {}
@@ -199,7 +199,9 @@ export async function generateInterceptor(
199
199
  `@see {${sourceName(name(replacePlugin))}} for source of replaced component`,
200
200
  )
201
201
  } else {
202
- pluginSee.push(`@see {@link file://./${targetExport}.tsx} for original source file`)
202
+ pluginSee.push(
203
+ `@see {@link file://./${targetExport}.original.tsx} for original source file`,
204
+ )
203
205
  }
204
206
 
205
207
  const pluginInterceptors = componentPlugins
@@ -259,7 +261,9 @@ export const ${targetExport} = ${carry}`
259
261
  `@see {${sourceName(name(replacePlugin))}} for source of replaced function`,
260
262
  )
261
263
  } else {
262
- pluginSee.push(`@see {@link file://./${targetExport}.ts} for original source file`)
264
+ pluginSee.push(
265
+ `@see {@link file://./${targetExport}.original.ts} for original source file`,
266
+ )
263
267
  }
264
268
 
265
269
  const pluginInterceptors = functionPlugins