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

Cannot import assemblyscript module #663

Closed
Remscar opened this issue May 19, 2021 · 10 comments
Closed

Cannot import assemblyscript module #663

Remscar opened this issue May 19, 2021 · 10 comments
Assignees

Comments

@Remscar
Copy link

Remscar commented May 19, 2021

I've been trying to import the assemblyscript-regex npm package which is an assembly script library that provides RegEx. (https://www.npmjs.com/package/assemblyscript-regex)

I import the package like:

import { Match, RegExp } from "assemblyscript-regex";

and when i try to run graph build i get the following error:

× Failed to compile subgraph: Failed to compile data source mapping: Import file '~lib/assemblyscript-regex.ts' not found.     
Error: Failed to compile data source mapping: Import file '~lib/assemblyscript-regex.ts' not found.
    at Compiler._compileDataSourceMapping (E:\dOrg\xxx-subgraph\node_modules\@graphprotocol\graph-cli\src\compiler.js:312:13)  
    at E:\dOrg\xxx-subgraph\node_modules\@graphprotocol\graph-cli\src\compiler.js:206:20
    at updateInDeepMap (E:\dOrg\xxx-subgraph\node_modules\immutable\dist\immutable.js:1971:22)
    at updateInDeepMap (E:\dOrg\xxx-subgraph\node_modules\immutable\dist\immutable.js:1980:23)
    at updateInDeepMap (E:\dOrg\xxx-subgraph\node_modules\immutable\dist\immutable.js:1980:23)
    at Map.updateIn (E:\dOrg\xxx-subgraph\node_modules\immutable\dist\immutable.js:1278:26)
    at E:\dOrg\xxx-subgraph\node_modules\@graphprotocol\graph-cli\src\compiler.js:205:24
    at E:\dOrg\xxx-subgraph\node_modules\immutable\dist\immutable.js:3016:46
    at List.__iterate (E:\dOrg\zns-subgraph\node_modules\immutable\dist\immutable.js:2206:13)
    at IndexedIterable.mappedSequence.__iterateUncached (E:\dOrg\xxx-subgraph\node_modules\immutable\dist\immutable.js:3015:23)

I tried to just copy/paste the assembly script code into my src folder and use it through that but also ran into a number of compiler problems (such as 'operation not supported')

My understanding was that you could import other assemblyscript modules into subgraph modules. What am I doing wrong, or is this package just incompatible?

Versions:

"@graphprotocol/graph-cli": "^0.20.0",
"@graphprotocol/graph-ts": "^0.20.0",
"assemblyscript-regex": "^1.6.4",
@leoyvens
Copy link
Collaborator

We are working on upgrading our AS version so we can be compatible with the ecosystem.

@dewf
Copy link

dewf commented Jun 26, 2021

@leoyvens Can you tell us how big of a change this would be, thus how far on the horizon it might be? Like @Remscar, I need regex support and would also like to import the bulk of my own code as a library (because it's shared with another project).

Would this be something worth looking into for an 'amateur' (a reasonably competent developer, but totally unfamiliar with the codebase)? How far could somebody get just bumping the AS version and focusing on broken tests?

Thanks!

@schmidsi
Copy link
Member

@dewf No need to invest too much time into this. There is already a open pull-request where we are working on at the moment. That said, it will probably take some more weeks because it also is dependent on changes in the graph-node.

@azf20
Copy link
Contributor

azf20 commented Aug 27, 2021

Hi @dewf the latest version of AssemblyScript is now supported by graph-node v0.24.0, and there is an alpha release of graph-ts and graph-cli. As there are quite substantial changes from the previous version, there is a migration guide here by @otaviopace. Would be great if you can give it a try, and do let us know if you encounter any issues!

@dewf
Copy link

dewf commented Sep 3, 2021

@azf20 thanks for the heads-up. I was actually just waiting for the full release but since you asked nicely I decided to try to work with the alpha. Unfortunately I'm blocked on the same @derivedFrom field issue as the other person testing it, so I will try back in a week or two (my project has been on the backburner for awhile now so unfortunately I can't devote too much focus - so please don't give this any extra emphasis on my account)

@evaporei
Copy link
Contributor

evaporei commented Sep 3, 2021

The derivedFrom issue is a simple fix, I'll focus on it next week 🙂
Once it's merged and released I'll ping you here!

@nickadamson
Copy link

@otaviopace mind pinging me as well?

@cauta
Copy link

cauta commented Sep 19, 2021

can we use as external library now? i want to call external http request by as-fetch

@evaporei
Copy link
Contributor

The new version of AssemblyScript is finally supported by the new version of the graph-cli and graph-node 🎉 🎊

@Remscar @nickadamson @dewf if you folks can try it out, here's the migration guide 🙂

@cauta unfortunately you can't use as-fetch. Allowing HTTP requests in the subgraph would result to non-deterministic indexing (different results depending on where and when the request was done).

@evaporei evaporei self-assigned this Sep 21, 2021
@azf20
Copy link
Contributor

azf20 commented Oct 29, 2021

Hi! Hope the latest AssemblyScript import functionality is working for you @Remscar @nickadamson @dewf , closing this issue, please re-open if you are still having issues!

@azf20 azf20 closed this as completed Oct 29, 2021
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

8 participants