Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonJS bundle contains a syntax error #23

Closed
N2D4 opened this issue Dec 23, 2024 · 2 comments
Closed

CommonJS bundle contains a syntax error #23

N2D4 opened this issue Dec 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@N2D4
Copy link

N2D4 commented Dec 23, 2024

Bug report

Describe the bug

When I import pg-gateway with require (or my bundler transpiles my import calls into that), pg-gateway throws an import error.

To Reproduce

Using the PGlite example from the next branch, but with the imports at the top replaced by require, throws an error:

# index.cjs
const { PGlite } = require('@electric-sql/pglite');
const { createServer } = require('node:net');
const { fromNodeSocket } = require('pg-gateway/node');
$ node index.cjs
Debugger listening on ws://127.0.0.1:64418/6c461da5-f0a8-4d36-8ef9-e05ec5c48608
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Waiting for the debugger to disconnect...
/node_modules/.pnpm/pg-gateway@0.3.0-beta.3/node_modules/pg-gateway/dist/chunk-OSDXSGAD.cjs:1
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) ...........................................................................................................................................................................................; exports.n = zA; exports.o = L; exports.p = w; exports.q = m; exports.r = KI; exports.s = l; exports.t = XA; exports.u = uI; exports.v = sA; exports.w = BA;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

SyntaxError: Unexpected token ','
    at internalCompileFunction (node:internal/vm:73:18)
    .........

System information

  • Version of pg-gateway: 0.3.0-beta-3
  • Version of Node.js: 20.11.1
@N2D4 N2D4 added the bug Something isn't working label Dec 23, 2024
@gregnr
Copy link
Contributor

gregnr commented Dec 23, 2024

Thanks for reporting @N2D4. Looks like a bug with tsup: egoist/tsup#1124. Going to dig into this to see what our options are.

@gregnr
Copy link
Contributor

gregnr commented Dec 23, 2024

@N2D4 this should be fixed now in 0.3.0-beta.4 via #24. Would you mind giving this another try?

@gregnr gregnr closed this as completed Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants