@prisma/client-generator-ts 6.11.0-dev.3 → 6.11.0-dev.30

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/dist/index.js CHANGED
@@ -3431,6 +3431,12 @@ config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})`;
3431
3431
  // src/utils/buildGetWasmModule.ts
3432
3432
  var import_client_common10 = require("@prisma/client-common");
3433
3433
  var import_ts_pattern = require("ts-pattern");
3434
+ function buildDynamicRequireFn() {
3435
+ return `const dynamicRequireFn = async <const T extends string>(name: T) =>
3436
+ typeof __non_webpack_require__ === 'function'
3437
+ ? Promise.resolve(__non_webpack_require__(name))
3438
+ : await import(/* webpackIgnore: true */ name)`;
3439
+ }
3434
3440
  function buildGetWasmModule({
3435
3441
  component,
3436
3442
  runtimeName,
@@ -3450,9 +3456,12 @@ function buildGetWasmModule({
3450
3456
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3451
3457
 
3452
3458
  getQuery${capitalizedComponent}WasmModule: async () => {
3453
- const { readFile } = await import('node:fs/promises')
3459
+ ${buildDynamicRequireFn()}
3460
+
3461
+ // Note: we must use dynamic imports here to avoid bundling errors like \`Module parse failed: Unexpected character '' (1:0)\`.
3462
+ const { readFile } = await dynamicRequireFn('node:fs/promises')
3454
3463
  ${buildRequire(moduleFormat)}
3455
- const wasmModulePath = require.resolve(${JSON.stringify(wasmModulePath)})
3464
+ const wasmModulePath = _require.resolve(${JSON.stringify(wasmModulePath)})
3456
3465
  const wasmModuleBytes = await readFile(wasmModulePath)
3457
3466
 
3458
3467
  return new globalThis.WebAssembly.Module(wasmModuleBytes)
@@ -3476,8 +3485,8 @@ function buildRequire(moduleFormat) {
3476
3485
  if (moduleFormat === "cjs") {
3477
3486
  return "";
3478
3487
  }
3479
- return `const { createRequire } = await import('node:module')
3480
- const require = createRequire(import.meta.url)
3488
+ return `const { createRequire } = await dynamicRequireFn('node:module')
3489
+ const _require = createRequire(import.meta.url)
3481
3490
  `;
3482
3491
  }
3483
3492
 
@@ -6481,7 +6490,7 @@ var import_get_tsconfig = require("get-tsconfig");
6481
6490
  var import_ts_pattern2 = require("ts-pattern");
6482
6491
 
6483
6492
  // package.json
6484
- var version = "6.11.0-dev.3";
6493
+ var version = "6.11.0-dev.30";
6485
6494
 
6486
6495
  // src/module-format.ts
6487
6496
  function parseModuleFormat(format) {
package/dist/index.mjs CHANGED
@@ -3430,6 +3430,12 @@ config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})`;
3430
3430
  // src/utils/buildGetWasmModule.ts
3431
3431
  import { capitalize as capitalize6 } from "@prisma/client-common";
3432
3432
  import { match } from "ts-pattern";
3433
+ function buildDynamicRequireFn() {
3434
+ return `const dynamicRequireFn = async <const T extends string>(name: T) =>
3435
+ typeof __non_webpack_require__ === 'function'
3436
+ ? Promise.resolve(__non_webpack_require__(name))
3437
+ : await import(/* webpackIgnore: true */ name)`;
3438
+ }
3433
3439
  function buildGetWasmModule({
3434
3440
  component,
3435
3441
  runtimeName,
@@ -3449,9 +3455,12 @@ function buildGetWasmModule({
3449
3455
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3450
3456
 
3451
3457
  getQuery${capitalizedComponent}WasmModule: async () => {
3452
- const { readFile } = await import('node:fs/promises')
3458
+ ${buildDynamicRequireFn()}
3459
+
3460
+ // Note: we must use dynamic imports here to avoid bundling errors like \`Module parse failed: Unexpected character '' (1:0)\`.
3461
+ const { readFile } = await dynamicRequireFn('node:fs/promises')
3453
3462
  ${buildRequire(moduleFormat)}
3454
- const wasmModulePath = require.resolve(${JSON.stringify(wasmModulePath)})
3463
+ const wasmModulePath = _require.resolve(${JSON.stringify(wasmModulePath)})
3455
3464
  const wasmModuleBytes = await readFile(wasmModulePath)
3456
3465
 
3457
3466
  return new globalThis.WebAssembly.Module(wasmModuleBytes)
@@ -3475,8 +3484,8 @@ function buildRequire(moduleFormat) {
3475
3484
  if (moduleFormat === "cjs") {
3476
3485
  return "";
3477
3486
  }
3478
- return `const { createRequire } = await import('node:module')
3479
- const require = createRequire(import.meta.url)
3487
+ return `const { createRequire } = await dynamicRequireFn('node:module')
3488
+ const _require = createRequire(import.meta.url)
3480
3489
  `;
3481
3490
  }
3482
3491
 
@@ -6480,7 +6489,7 @@ import { getTsconfig } from "get-tsconfig";
6480
6489
  import { match as match2 } from "ts-pattern";
6481
6490
 
6482
6491
  // package.json
6483
- var version = "6.11.0-dev.3";
6492
+ var version = "6.11.0-dev.30";
6484
6493
 
6485
6494
  // src/module-format.ts
6486
6495
  function parseModuleFormat(format) {
@@ -10,4 +10,16 @@ export type BuildWasmModuleOptions = {
10
10
  activeProvider: ActiveConnectorType;
11
11
  moduleFormat: ModuleFormat;
12
12
  };
13
+ /**
14
+ * This function evaluates to:
15
+ * - `import(name)` for all bundler targets, except Webpack, but including Turbopack.
16
+ * - `__non_webpack_require__(name)` for Webpack targets.
17
+ *
18
+ * This is used to dynamically import a module at runtime, while also excluding it from Webpack's bundle.
19
+ * It allows to mitigate the following issues:
20
+ * - https://github.com/webpack/webpack/issues/19607
21
+ * - https://github.com/prisma/prisma/issues/27049
22
+ * - https://github.com/prisma/prisma/issues/27343
23
+ */
24
+ export declare function buildDynamicRequireFn(): string;
13
25
  export declare function buildGetWasmModule({ component, runtimeName, runtimeBase, target, activeProvider, moduleFormat, }: BuildWasmModuleOptions): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-generator-ts",
3
- "version": "6.11.0-dev.3",
3
+ "version": "6.11.0-dev.30",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -25,7 +25,7 @@
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
27
  "@antfu/ni": "0.21.12",
28
- "@prisma/engines-version": "6.11.0-1.09706cd7c13a662843f8f7f16e6128aedbee4654",
28
+ "@prisma/engines-version": "6.11.0-15.f67607f6772d3f263d40c8e233b50714bc8295cc",
29
29
  "ci-info": "4.2.0",
30
30
  "fast-glob": "3.3.3",
31
31
  "get-tsconfig": "4.10.0",
@@ -34,14 +34,14 @@
34
34
  "pkg-up": "3.1.0",
35
35
  "pluralize": "8.0.0",
36
36
  "ts-pattern": "5.6.2",
37
- "@prisma/client-common": "6.11.0-dev.3",
38
- "@prisma/dmmf": "6.11.0-dev.3",
39
- "@prisma/generator": "6.11.0-dev.3",
40
- "@prisma/fetch-engine": "6.11.0-dev.3",
41
- "@prisma/debug": "6.11.0-dev.3",
42
- "@prisma/get-platform": "6.11.0-dev.3",
43
- "@prisma/internals": "6.11.0-dev.3",
44
- "@prisma/ts-builders": "6.11.0-dev.3"
37
+ "@prisma/client-common": "6.11.0-dev.30",
38
+ "@prisma/debug": "6.11.0-dev.30",
39
+ "@prisma/dmmf": "6.11.0-dev.30",
40
+ "@prisma/generator": "6.11.0-dev.30",
41
+ "@prisma/fetch-engine": "6.11.0-dev.30",
42
+ "@prisma/internals": "6.11.0-dev.30",
43
+ "@prisma/ts-builders": "6.11.0-dev.30",
44
+ "@prisma/get-platform": "6.11.0-dev.30"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/pluralize": "0.0.33",