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

The symbol "Stats" has already been declared #122

Open
lastmjs opened this issue Jan 4, 2024 · 9 comments
Open

The symbol "Stats" has already been declared #122

lastmjs opened this issue Jan 4, 2024 · 9 comments

Comments

@lastmjs
Copy link

lastmjs commented Jan 4, 2024

Hi, I'm incorporating wasmedge-quickjs into my own project that doesn't use wasmedge as a runtime, and I'm trying to get the fs module to work.

I get this error when I try to import it with my bundling process: TypeScript error: The symbol "Stats" has already been declared

It seems pretty obvious why this is the case, see here: https://github.com/second-state/wasmedge-quickjs/blob/main/modules/internal/fs.js#L2

Stats is both imported and there is a local class called Stats as well. This is not allowed.

@lastmjs
Copy link
Author

lastmjs commented Jan 4, 2024

This seems to be happening with various files, I'll put them in here as comments:

TypeScript error: The symbol "debuglog" has already been declared

https://github.com/second-state/wasmedge-quickjs/blob/main/modules/util.js#L2

@lastmjs
Copy link
Author

lastmjs commented Jan 4, 2024

TypeScript error: The symbol "promisify" has already been declared

https://github.com/second-state/wasmedge-quickjs/blob/main/modules/util.js#L1

@lastmjs
Copy link
Author

lastmjs commented Jan 4, 2024

TypeScript error: The symbol "deprecate" has already been declared

https://github.com/second-state/wasmedge-quickjs/blob/main/modules/util.js#L1

@juntao
Copy link
Member

juntao commented Jan 5, 2024

Running this project outside of WasmEdge could have a lot of WASI challenges. WASI preview 1 simply does not define a lot of host functions required in nodejs.

@lastmjs
Copy link
Author

lastmjs commented Jan 15, 2024

These are just basic JS issues.

Stats is both imported and there is a local class called Stats as well. This is not allowed.

The build process you all have seems to ignore the issues for some reason. You'll notice in the OP that I point out the issue directly, you can't import something with the same name as a class in the same module/file.

These errors are repeated a couple times.

@lastmjs
Copy link
Author

lastmjs commented Jan 15, 2024

This is similar to what's happening various times in the wasmedge-quickjs codebase: https://www.typescriptlang.org/play?ssl=1&ssc=10&pln=1&pc=22#code/JYWwDg9gTgLgBAbzlApgQwCYDFgBsUDKAngHYDGcAvnAGZQQhwDkNAzkwNwBQXZuarVsnTY8hUhQSUgA

@L-jasmine
Copy link
Collaborator

I'm very sorry, I will fix them as soon as possible.

@L-jasmine
Copy link
Collaborator

May I ask how you got these warnings? Are you using TypeScript, or did you simply import these problematic modules?

@lastmjs
Copy link
Author

lastmjs commented Jan 25, 2024

We are using TypeScript yes, but specifically esbuild as our bundler. Our Wasm binaries must then run in Node's Wasm environment and the Internet Computer's Wasmtime environment.

Here's the most important part of our build process: https://github.com/demergent-labs/azle/blob/main/src/compiler/compile_typescript_code.ts#L56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants