Git Product home page Git Product logo

Comments (18)

scalemaildev avatar scalemaildev commented on July 2, 2024 3

I got around this by using NuxtJS's transpile feature in its config file. Depending on what framework you're using, you should have some method of transpiling modules.

from hashconnect.

kkartunov avatar kkartunov commented on July 2, 2024 2

Actually it works with NextJS but one has to use https://www.npmjs.com/package/next-transpile-modules
Thanks for the tip @scalemaildev !

from hashconnect.

franfernandez20 avatar franfernandez20 commented on July 2, 2024 1

Any news or resolution of this? I am having this issue importing anything from the package.

from hashconnect.

samuelnihoul avatar samuelnihoul commented on July 2, 2024

This can be quickfixed by renaming main.ts or main.js to main.mjs or main.mts

from hashconnect.

samuelnihoul avatar samuelnihoul commented on July 2, 2024

This issue should be labelled as breaking

from hashconnect.

samuelnihoul avatar samuelnihoul commented on July 2, 2024

How did you circumvent the issue @joelviel?

from hashconnect.

joelviel avatar joelviel commented on July 2, 2024

Indeed it is a blocking issue, can you fix it and make a stable release? I am trying to make a project for hedera22 hackathon.

from hashconnect.

TheMagnat avatar TheMagnat commented on July 2, 2024

Same issue. I can't manage to make It work. I tried basic import from documentation and it give me the error.

from hashconnect.

kkartunov avatar kkartunov commented on July 2, 2024

+1
Having same issue with NextJS. Here is error stack:

Server Error
SyntaxError: Unexpected token 'export'

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///home/kiril/dev/metasnap/meta-web/node_modules/hashconnect/dist/main.js (1)
...

from hashconnect.

idrissyed7 avatar idrissyed7 commented on July 2, 2024

@teacoat Do we know when this issue will be resolved? We are trying to use this package on a new Svelte-Kit project but couldn't move forward because of this bug.

from hashconnect.

teacoat avatar teacoat commented on July 2, 2024

This can be quickfixed by renaming main.ts or main.js to main.mjs or main.mts

It looks like there is are some .mjs and .mts files in the dist already,
image

Can you provide a project I can reproduce this in?

from hashconnect.

pwoosam avatar pwoosam commented on July 2, 2024

Here is a sample project to reproduce the error.
https://github.com/pwoosam/hashconnect-ts-bug

After cloning, run:

  1. npm i
  2. npm run start

from hashconnect.

pwoosam avatar pwoosam commented on July 2, 2024

As a work around, I can clone the repo and compile as a CommonJS module by setting these fields in tsconfig.json:
"target": "ESNext",
"module": "CommonJS",

There are some additional issues that require more modification to work in a node environment (non-browser).
Such as installing polyfills for WebSocket and localstorage. Also removing references to window from the sourcecode.

from hashconnect.

sergioaiobuilders avatar sergioaiobuilders commented on July 2, 2024

@pwoosam Just tried your PR and it works great! @teacoat when will it be merged?

from hashconnect.

mrVers avatar mrVers commented on July 2, 2024

Seems this issue is still present as of 0.2.3, getting the same error message.

from hashconnect.

pwoosam avatar pwoosam commented on July 2, 2024

@mrVers did you try importing the cjs library?

import { HashConnect } from 'hashconnect/dist/cjs/main';

from hashconnect.

mrVers avatar mrVers commented on July 2, 2024

@pwoosam No luck. I'm trying this on a React/NextJS project.
Even if I try your simple project https://github.com/pwoosam/hashconnect-ts-bug with the latest 0.2.3. I'm seeing the same issue.

from hashconnect.

scalemaildev avatar scalemaildev commented on July 2, 2024

Was playing around in my old repos and discovered this problem appears to now be fixed in Nuxt3 latest.

from hashconnect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.