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

build error with assemblyscript 0.19+ #376

Open
achille-roussel opened this issue Dec 8, 2021 · 5 comments
Open

build error with assemblyscript 0.19+ #376

achille-roussel opened this issue Dec 8, 2021 · 5 comments

Comments

@achille-roussel
Copy link

This seems to be related to the visitor-as package having compatibility issues with the latest assemblyscript version:

Testing on a minimal setup following the documentation of https://tenner-joshua.gitbook.io/as-pect/getting-started, and adding this to the as-pect.config.json file:

  flags: {
    "transform": ["json-as/transform"]
  }
$ npx asp
...
[Error] There was a compilation error when trying to create the wasm binary for file: assembly/__tests__/example.spec.ts.
Error: Cannot find module 'visitor-as/as'
Require stack:
- /private/tmp/json-as-test/node_modules/json-as/transform/lib/index.js
- /private/tmp/json-as-test/node_modules/assemblyscript/cli/asc.js
- /private/tmp/json-as-test/node_modules/@as-pect/cli/lib/run.js
- /private/tmp/json-as-test/node_modules/@as-pect/cli/lib/index.js
- /private/tmp/json-as-test/node_modules/@as-pect/cli/lib/test.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/private/tmp/json-as-test/node_modules/json-as/transform/lib/index.js:2:14)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.main (/private/tmp/json-as-test/node_modules/assemblyscript/cli/asc.js:567:25)
    at /private/tmp/json-as-test/node_modules/@as-pect/cli/lib/run.js:624:17
    at Array.forEach (<anonymous>)
    at run (/private/tmp/json-as-test/node_modules/@as-pect/cli/lib/run.js:622:36) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/private/tmp/json-as-test/node_modules/json-as/transform/lib/index.js',
    '/private/tmp/json-as-test/node_modules/assemblyscript/cli/asc.js',
    '/private/tmp/json-as-test/node_modules/@as-pect/cli/lib/run.js',
    '/private/tmp/json-as-test/node_modules/@as-pect/cli/lib/index.js',
    '/private/tmp/json-as-test/node_modules/@as-pect/cli/lib/test.js'
  ]
}

I reported it there as well as-pect/visitor-as#32 but wanted to raise the issue for completeness.

@achille-roussel
Copy link
Author

I worked around the issue by running the following:

$ npm install --save-dev --force visitor-as

Tho it seems code generation results in duplicate symbols now:

$ npx asp
       ___   _____                       __
      /   | / ___/      ____  ___  _____/ /_
     / /| | \__ \______/ __ \/ _ \/ ___/ __/
    / ___ |___/ /_____/ /_/ /  __/ /__/ /_
   /_/  |_/____/     / .___/\___/\___/\__/
                    /_/

⚡AS-pect⚡ Test suite runner [6.2.4]

[Log] Loading asc compiler
Assemblyscript Folder:assemblyscript
[Log] Compiler loaded in 310.427ms.
[Log] Using configuration /private/tmp/json-as-test/as-pect.config.js
[Log] Using SummaryReporter
[Log] Including files: assembly/__tests__/**/*.spec.ts
[Log] Running tests that match: (:?)
[Log] Running groups that match: (:?)
[Log] Effective command line args:
  [TestFile.ts] node_modules/@as-pect/assembly/assembly/index.ts --runtime incremental --transform json-as/transform,/private/tmp/json-as-test/node_modules/@as-pect/core/lib/transform/index.js --debug --binaryFile output.wasm --explicitStart --use ASC_RTRACE=1 --exportTable --importMemory

ERROR TS2300: Duplicate identifier '__encoded'.

 __encoded: string = ''
 ~~~~~~~~~
 in assembly/__tests__/example.spec.ts(1,1)

 __encoded: string = ''
 ~~~~~~~~~
 in assembly/__tests__/example.spec.ts(1,1)

ERROR TS2300: Duplicate identifier '__encode'.

       __encode(): void {
       ~~~~~~~~
 in assembly/__tests__/example.spec.ts(2,7)

       __encode(): void {
       ~~~~~~~~
 in assembly/__tests__/example.spec.ts(2,7)

...

@jtenner
Copy link
Contributor

jtenner commented Jan 13, 2022

@willemneal what do you think this is?

@willemneal
Copy link
Collaborator

My guess is that it's performing a transform that adds the extra methods that are the same.

You could try this one: https://github.com/gagdiez/serial-as/tree/main/json

@willemneal
Copy link
Collaborator

Don't think the decorator is needed. Here is that repo's aspect config

https://github.com/gagdiez/serial-as/blob/main/as-pect.config.js

@achille-roussel
Copy link
Author

I have looked further into this, and I am not sure that the json-as/transform package was correct, it may just be an implementation issue on that side and unrelated to as-pect.

I don't have concrete data to determine where things broke exactly, I ended up working around the issue by taking a different approach.

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