prisma-flare 1.1.5 → 1.1.6

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.
@@ -349,6 +349,11 @@ function resolvePrismaClientPath(rootDir, output) {
349
349
  }
350
350
  const schemaDir = path4.join(rootDir, "prisma");
351
351
  const absolutePath = path4.resolve(schemaDir, output);
352
+ const clientEntryPath = path4.join(absolutePath, "client.ts");
353
+ const clientEntryPathJs = path4.join(absolutePath, "client.js");
354
+ if (fs4.existsSync(clientEntryPath) || fs4.existsSync(clientEntryPathJs)) {
355
+ return path4.join(absolutePath, "client");
356
+ }
352
357
  return absolutePath;
353
358
  }
354
359
  function getPrismaClientPath(rootDir) {
@@ -371,6 +376,25 @@ function hasCustomPrismaOutput(rootDir) {
371
376
  }
372
377
 
373
378
  // src/cli/generate-client.ts
379
+ function createSymlinkSafe(target, linkPath) {
380
+ try {
381
+ if (fs5.existsSync(linkPath)) {
382
+ const stats = fs5.lstatSync(linkPath);
383
+ if (stats.isSymbolicLink()) {
384
+ fs5.unlinkSync(linkPath);
385
+ } else if (stats.isDirectory()) {
386
+ fs5.rmSync(linkPath, { recursive: true });
387
+ } else {
388
+ fs5.unlinkSync(linkPath);
389
+ }
390
+ }
391
+ const linkType = process.platform === "win32" ? "junction" : "dir";
392
+ fs5.symlinkSync(target, linkPath, linkType);
393
+ return true;
394
+ } catch (error) {
395
+ return false;
396
+ }
397
+ }
374
398
  function generateClient() {
375
399
  const rootDir = findProjectRoot(process.cwd());
376
400
  const config = loadConfig(rootDir);
@@ -386,14 +410,27 @@ function generateClient() {
386
410
  fs5.mkdirSync(prismaFlareDir, { recursive: true });
387
411
  }
388
412
  let resolvedImport;
413
+ let useSymlink = false;
389
414
  if (prismaClientImport === "@prisma/client") {
390
415
  resolvedImport = "@prisma/client";
391
416
  } else {
392
- resolvedImport = path5.relative(prismaFlareDir, prismaClientImport);
393
- if (!resolvedImport.startsWith(".")) {
394
- resolvedImport = "./" + resolvedImport;
417
+ const symlinkPath = path5.join(prismaFlareDir, "prisma-client");
418
+ let targetDir = prismaClientImport;
419
+ if (targetDir.endsWith("/client") || targetDir.endsWith("\\client")) {
420
+ targetDir = path5.dirname(targetDir);
421
+ }
422
+ if (createSymlinkSafe(targetDir, symlinkPath)) {
423
+ useSymlink = true;
424
+ const hasClientEntry = fs5.existsSync(path5.join(targetDir, "client.ts")) || fs5.existsSync(path5.join(targetDir, "client.js"));
425
+ resolvedImport = hasClientEntry ? "./prisma-client/client" : "./prisma-client";
426
+ } else {
427
+ console.warn("\u26A0\uFE0F Could not create symlink. Some bundlers may have issues with the generated import path.");
428
+ resolvedImport = path5.relative(prismaFlareDir, prismaClientImport);
429
+ if (!resolvedImport.startsWith(".")) {
430
+ resolvedImport = "./" + resolvedImport;
431
+ }
432
+ resolvedImport = resolvedImport.replace(/\\/g, "/");
395
433
  }
396
- resolvedImport = resolvedImport.replace(/\\/g, "/");
397
434
  }
398
435
  const isCustomOutput = hasCustomPrismaOutput(rootDir);
399
436
  const esmContent = `// Generated by prisma-flare - DO NOT EDIT
@@ -483,6 +520,9 @@ export declare class FlareClient extends BasePrismaClient {
483
520
  );
484
521
  if (isCustomOutput) {
485
522
  console.log(`\u2705 Generated prisma-flare client with custom Prisma output: ${prismaClientImport}`);
523
+ if (useSymlink) {
524
+ console.log(` Using symlink for bundler compatibility`);
525
+ }
486
526
  } else {
487
527
  console.log(`\u2705 Generated prisma-flare client using @prisma/client`);
488
528
  }
package/dist/cli/index.js CHANGED
@@ -326,6 +326,11 @@ function resolvePrismaClientPath(rootDir, output) {
326
326
  }
327
327
  const schemaDir = path4.join(rootDir, "prisma");
328
328
  const absolutePath = path4.resolve(schemaDir, output);
329
+ const clientEntryPath = path4.join(absolutePath, "client.ts");
330
+ const clientEntryPathJs = path4.join(absolutePath, "client.js");
331
+ if (fs4.existsSync(clientEntryPath) || fs4.existsSync(clientEntryPathJs)) {
332
+ return path4.join(absolutePath, "client");
333
+ }
329
334
  return absolutePath;
330
335
  }
331
336
  function getPrismaClientPath(rootDir) {
@@ -348,6 +353,25 @@ function hasCustomPrismaOutput(rootDir) {
348
353
  }
349
354
 
350
355
  // src/cli/generate-client.ts
356
+ function createSymlinkSafe(target, linkPath) {
357
+ try {
358
+ if (fs5.existsSync(linkPath)) {
359
+ const stats = fs5.lstatSync(linkPath);
360
+ if (stats.isSymbolicLink()) {
361
+ fs5.unlinkSync(linkPath);
362
+ } else if (stats.isDirectory()) {
363
+ fs5.rmSync(linkPath, { recursive: true });
364
+ } else {
365
+ fs5.unlinkSync(linkPath);
366
+ }
367
+ }
368
+ const linkType = process.platform === "win32" ? "junction" : "dir";
369
+ fs5.symlinkSync(target, linkPath, linkType);
370
+ return true;
371
+ } catch (error) {
372
+ return false;
373
+ }
374
+ }
351
375
  function generateClient() {
352
376
  const rootDir = findProjectRoot(process.cwd());
353
377
  const config = loadConfig(rootDir);
@@ -363,14 +387,27 @@ function generateClient() {
363
387
  fs5.mkdirSync(prismaFlareDir, { recursive: true });
364
388
  }
365
389
  let resolvedImport;
390
+ let useSymlink = false;
366
391
  if (prismaClientImport === "@prisma/client") {
367
392
  resolvedImport = "@prisma/client";
368
393
  } else {
369
- resolvedImport = path5.relative(prismaFlareDir, prismaClientImport);
370
- if (!resolvedImport.startsWith(".")) {
371
- resolvedImport = "./" + resolvedImport;
394
+ const symlinkPath = path5.join(prismaFlareDir, "prisma-client");
395
+ let targetDir = prismaClientImport;
396
+ if (targetDir.endsWith("/client") || targetDir.endsWith("\\client")) {
397
+ targetDir = path5.dirname(targetDir);
398
+ }
399
+ if (createSymlinkSafe(targetDir, symlinkPath)) {
400
+ useSymlink = true;
401
+ const hasClientEntry = fs5.existsSync(path5.join(targetDir, "client.ts")) || fs5.existsSync(path5.join(targetDir, "client.js"));
402
+ resolvedImport = hasClientEntry ? "./prisma-client/client" : "./prisma-client";
403
+ } else {
404
+ console.warn("\u26A0\uFE0F Could not create symlink. Some bundlers may have issues with the generated import path.");
405
+ resolvedImport = path5.relative(prismaFlareDir, prismaClientImport);
406
+ if (!resolvedImport.startsWith(".")) {
407
+ resolvedImport = "./" + resolvedImport;
408
+ }
409
+ resolvedImport = resolvedImport.replace(/\\/g, "/");
372
410
  }
373
- resolvedImport = resolvedImport.replace(/\\/g, "/");
374
411
  }
375
412
  const isCustomOutput = hasCustomPrismaOutput(rootDir);
376
413
  const esmContent = `// Generated by prisma-flare - DO NOT EDIT
@@ -460,6 +497,9 @@ export declare class FlareClient extends BasePrismaClient {
460
497
  );
461
498
  if (isCustomOutput) {
462
499
  console.log(`\u2705 Generated prisma-flare client with custom Prisma output: ${prismaClientImport}`);
500
+ if (useSymlink) {
501
+ console.log(` Using symlink for bundler compatibility`);
502
+ }
463
503
  } else {
464
504
  console.log(`\u2705 Generated prisma-flare client using @prisma/client`);
465
505
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-flare",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Prisma utilities package with callback system and query builder for chained operations",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",