-
-
Notifications
You must be signed in to change notification settings - Fork 673
Cannot find module 'assemblyscript/asc' or its corresponding type declarations. #2241
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
Comments
If I ignore the errors and run it in JavaScript anyways, Node gives me the error |
This is a relatively recent change (in v0.20). What's the version of the compiler you are using? |
@dcodeIO I have version 0.20.2 installed. |
Toying around with this a little, seems the import can be resolved when adding import asc from "assemblyscript/asc"; stating
which seems just as odd, as it doesn't go away even when adding There is another hint, however, stating
which I haven't tested. Perhaps it's simply not supported by stable TS yet? |
That's unfortunate. I didn't realize it was ESM-only; I'm using CommonJS for imports, so that's probably why it's broken. |
@dcodeIO I got it to work in TypeScript 4.5.5 by using |
I am seeing very strange behavior when I do this. For example, the following code logs out several megabytes, mostly base-64-encoded data: import asc from "assemblyscript/dist/asc.js";
throw new Error(); |
I believe that's because Node.js by default doesn't load source maps, and somehow believes that printing all minified code on the same line is of great use. Could also be connected to Binaryen's Emscripten output, not sure, so perhaps not Node. Nonetheless, providing Line 71 in 9c0db25
|
Yep, |
My intuition here is that, when it works in plain JS, this would be an incompatibility of TS with Node's new |
@dcodeIO No, but I currently can't compile at all with |
Before trying Typescript just try to import it from js for starters. I'm getting At least I'm using Node |
@jerrygreen I couldn't import it from the Node REPL or a commonjs script. I had to either save it as a |
I have |
I downgrade to 0.19.23 and it works |
I tried to update to the newest assemblyscript in the as-loader library (a webpack loader for assemblyscript). Unfortunately, ESM doesn't work well with webpack... Would it be possible to provide a CJS format too? I feel like the node environment is not fully ready for the switch to ESM. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions! |
This is still an issue |
After spending the whole day upgrading my nestjs backend to use ESM modules I had at first no luck. Additionally just supressing the error with: // @ts-ignore did the trick. The latest version of the ASC compiler works fine now in my backend. Besides with nodejs 18.2.0 |
I don't like to use |
Actually the issue is not an issue if all those requirements are met:
Break any of it and you gonna have a bad time :( |
Yep - especially when you build a package for another tool that didn't migrate to ESM :/ I cannot use new bindings stuff for the as-loader for webpack, because webpack doesn't support ESM |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions! |
Uh oh!
There was an error while loading. Please reload this page.
The website says it's possible to call
asc
programmatically in JavaScript, and can be imported as follows:Source: Programmatic usage
However, trying to do so in TypeScript fails with the error message from the title. There is no
@types/assemblyscript
package either, at least not that yarn can find.TypeScript seems to think the module is called
assemblyscript/dist/asc
, as I can import that with no such error.The text was updated successfully, but these errors were encountered: