kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.22k stars 260 forks source link

BigInt literal in 0.23.5 breaks esbuild with older target #373

Closed yqkqknct closed 1 year ago

yqkqknct commented 1 year ago

We're using Vite (which using esbuild) to build production code for browser. Our build target is "chrome64", "edge79", "es2020", "firefox67", "safari12" and it throws the error during build. A prior issue seems to solve the big int literal issue https://github.com/koskimas/kysely/issues/142 but the issue seems to be back in 0.23.5, in commit https://github.com/koskimas/kysely/commit/278d31f472f724a3a84c22146e2d4b23063cd36e Therefore, we downgrade to 0.23.4 and the build process went well. I guess this can be using BigInt(0) syntax as well, similar to this fix (https://github.com/koskimas/kysely/issues/142)?

Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 2 overrides)
91289|              new DeleteResult(
91290|              // TODO: remove numUpdatedOrDeletedRows.
91291|              result.numAffectedRows ?? result.numUpdatedOrDeletedRows ?? 0n),
   |                                                                          ^
91292|          ];
91293|      }

Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 2 overrides)
91725|              new UpdateResult(
91726|              // TODO: remove numUpdatedOrDeletedRows.
91727|              result.numAffectedRows ?? result.numUpdatedOrDeletedRows ?? 0n),
   |                                                                          ^
91728|          ];
91729|      }

error during build:
Error: Transform failed with 2 errors:
assets/index-!~{001}~.js:91291:72: ERROR: Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 2 overrides)
assets/index-!~{001}~.js:91727:72: ERROR: Big integer literals are not available in the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari12" + 2 overrides)
koskimas commented 1 year ago

Yeah, I can fix this but as I mentioned in the original issue, this will probably keep on breaking since we have a minimum feature requirement (as a form of node version). No tests catch this error since old versions that don't support bigint literals are not officially supported. You should fix this by changing the target environment if possible.