absinthe-graphql / absinthe-socket

Core JavaScript support for Absinthe WS-based operations
MIT License
148 stars 75 forks source link

Uncaught TypeError: Cannot instantiate an arrow function #59

Closed Hermanverschooten closed 1 year ago

Hermanverschooten commented 3 years ago

When using parcel v2, or esbuild the generated JS code, causes the above error when calling AbsintheSocket.create.

I was after some trial and error able to make it working again for esbuild by using require instead of import.

// import * as AbsintheSocket from "@absinthe/socket";
const AbsintheSocket = require('@absinthe/socket');

This did not work with parcel however.

I cloned José Valim's esbuild test repo to replicate the error, https://github.com/Hermanverschooten/phx_esbuild_demo, branch test_absinthe

neurodynamic commented 2 years ago

I'm also seeing this issue.

@Hermanverschooten Your require fix works for me; thanks for posting it!

neurodynamic commented 2 years ago

@Hermanverschooten Shot in the dark, but you wouldn't have any idea why using esbuild's inject feature might cause this bug to come back even if you're using the require trick, would you? I'm at a loss.

Hermanverschooten commented 2 years ago

@neurodynamic No I am sorry, no clue. Sorry about the delay, I was traveling. But if you find out, please share.

jzwood commented 1 year ago

Trying to migrate to Parcel and running into the same thing. Neither import strategy works. 😕

Hermanverschooten commented 1 year ago

I gave up on Parcel long time ago and since moving to the esbuild hex package and using the require solution I have had no more issues.

RichMatthews commented 1 year ago

@Hermanverschooten I'm still seeing this issue. even with the require method. I'm using @absinthe/socket-apollo-link version 0.2.1. phoenix version 1.7.1. Anything else I need to do?

Hermanverschooten commented 1 year ago

@RichMatthews I am still using the require method, I must say my phoenix is still at 1.6.15 for that project.