JairusSW / as-json

The only JSON library you'll need for AssemblyScript. SIMD enabled
MIT License
79 stars 15 forks source link

Error building the project with as-json #72

Closed spino17 closed 5 months ago

spino17 commented 5 months ago

I installed the as-json and tried to build the project with npm run asbuild. It is giving below error: FAILURE Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'visitor-as' imported from.

I have followed the instructions of attaching the --transform option etc.

mattjohnsonpint commented 5 months ago

I'm not sure if there's a better way, but what I've had success with is as follows:

  1. npm install json-as
  2. add the following to the package.json file manually:
    "overrides": {
    "assemblyscript": "$assemblyscript"
    }
  3. npm install -D visitor-as

The resulting package.json should have all of the following (with whatever the current versions are):

  "dependencies": {
    "json-as": "^0.8.4"
  },
  "devDependencies": {
    "assemblyscript": "^0.27.27",
    "visitor-as": "^0.11.4"
  },
  "overrides": {
    "assemblyscript": "$assemblyscript"
  }

And then, yes - you still need the transform, either on the command line when calling asc, or in the asconfig.json.

spino17 commented 5 months ago

Yeah installing visitor-as also solved the issue. The docs nowhere mention to install this as well. It will be great if that is included in the docs as well. Much Thanks for the help :), it worked like a charm

JairusSW commented 5 months ago

I made it so that the end user can install a different version of visitor-as say if they were targeting AssemblyScript v18.x.x, they would install an older version for compat. So, that's why you need to install visitor-as manually. I try to keep this lib backwards compatible with older versions :)