GithubHelp home page GithubHelp logo

Comments (2)

guybedford avatar guybedford commented on May 31, 2024

@danbev nothing immediately comes to mind here unfortunately. One thing you might want to try here is a jco --version check between the two commands. If you have a repo I can try happy to look into it further.

Edit: this is definitely a versioning issue - blasting node_modules and reinstalling, and making sure to use ./node_modules/.bin/jco over the global jco would make sense.

from jco.

danbev avatar danbev commented on May 31, 2024

@guybedford Thanks for your reply and suggestions!

I've been trying this out using the repository's main branch and I can reproduce the error using the jco.sh script:

build and reproducer output
$ git clone [email protected]:bytecodealliance/jco.git
Cloning into 'jco'...
remote: Enumerating objects: 1790, done.
remote: Counting objects: 100% (810/810), done.
remote: Compressing objects: 100% (449/449), done.
remote: Total 1790 (delta 486), reused 525 (delta 340), pack-reused 980
Receiving objects: 100% (1790/1790), 4.84 MiB | 6.78 MiB/s, done.
Resolving deltas: 100% (897/897), done.
$ cd jco/
$ npm i

added 218 packages, and audited 220 packages in 15s

60 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$ npm run build

> build
> npm run build:set-last && npm run build:dev && ./build-dist.sh


> build:set-last
> echo './node_modules/.bin/jco $@' > jco.sh && chmod +x jco.sh


> build:dev
> npm run build:wasm && mkdir -p obj && npm run build:js-component-bindgen-component && npm run build:wasm-tools


> build:wasm
> cargo build --workspace --target wasm32-unknown-unknown --release

   Compiling proc-macro2 v1.0.56
   Compiling unicode-ident v1.0.8
   Compiling quote v1.0.26
   Compiling serde v1.0.160
   Compiling serde_derive v1.0.160
   Compiling autocfg v1.1.0
   Compiling version_check v0.9.4
   Compiling memchr v2.5.0
   Compiling anyhow v1.0.70
   Compiling tinyvec_macros v0.1.1
   Compiling hashbrown v0.12.3
   Compiling log v0.4.17
   Compiling tinyvec v1.6.0
   Compiling percent-encoding v2.2.0
   Compiling unicode-bidi v0.3.13
   Compiling form_urlencoded v1.1.0
   Compiling unicase v2.6.0
   Compiling cfg-if v1.0.0
   Compiling indexmap v1.9.3
   Compiling pulldown-cmark v0.8.0
   Compiling leb128 v0.2.5
   Compiling wasm-encoder v0.26.0
   Compiling ahash v0.8.3
   Compiling bitflags v1.3.2
   Compiling unicode-width v0.1.10
   Compiling id-arena v2.2.1
   Compiling unicode-xid v0.2.4
   Compiling crc32fast v1.3.2
   Compiling unicode-normalization v0.1.22
   Compiling thiserror v1.0.40
   Compiling syn v2.0.15
   Compiling unicode-segmentation v1.10.1
   Compiling wast v57.0.0
   Compiling wit-bindgen-rust v0.6.0
   Compiling target-lexicon v0.12.6
   Compiling idna v0.3.0
   Compiling heck v0.4.1
   Compiling once_cell v1.17.1
   Compiling url v2.3.1
   Compiling hashbrown v0.13.2
   Compiling stable_deref_trait v1.2.0
   Compiling fallible-iterator v0.2.0
   Compiling wasm-encoder v0.25.0
   Compiling wasmtime-component-util v8.0.1
   Compiling bitflags v2.2.1
   Compiling base64 v0.21.0
   Compiling thiserror-impl v1.0.40
   Compiling wat v1.0.63
   Compiling cranelift-entity v0.95.1
   Compiling wasmparser v0.104.0
   Compiling wit-parser v0.7.1
   Compiling wasmparser v0.102.0
   Compiling object v0.30.3
   Compiling gimli v0.27.2
   Compiling wasmtime-types v8.0.1
   Compiling wasm-metadata v0.5.0
   Compiling wit-component v0.8.2
   Compiling wasmprinter v0.2.56
   Compiling wasmtime-environ v8.0.1
   Compiling wit-bindgen-core v0.6.0
   Compiling wit-bindgen-rust-lib v0.6.0
   Compiling wit-bindgen-rust-macro v0.6.0
   Compiling wit-bindgen v0.6.0
   Compiling js-component-bindgen v0.1.0 (/home/danielbevenius/work/wasm/tmp/jco/crates/js-component-bindgen)
   Compiling jco v0.1.0 (/home/danielbevenius/work/wasm/tmp/jco)
   Compiling wasm-tools-js v0.1.0 (/home/danielbevenius/work/wasm/tmp/jco/crates/wasm-tools-component)
   Compiling js-component-bindgen-component v0.1.0 (/home/danielbevenius/work/wasm/tmp/jco/crates/js-component-bindgen-component)
    Finished release [optimized] target(s) in 37.30s

> build:js-component-bindgen-component
> npm run build:component:js-component-bindgen-component && npm run build:transpile:js-component-bindgen-component


> build:component:js-component-bindgen-component
> ./jco.sh new target/wasm32-unknown-unknown/release/js_component_bindgen_component.wasm -o obj/js-component-bindgen-component.wasm


> build:transpile:js-component-bindgen-component
> ./jco.sh transpile obj/js-component-bindgen-component.wasm --map console=../lib/console.js --out-dir obj


Transpiled JS Component Files:

 - obj/exports/exports.d.ts                      0.67 KiB
 - obj/imports/console.d.ts                      0.07 KiB
 - obj/js-component-bindgen-component.core.wasm  4.61 MiB
 - obj/js-component-bindgen-component.d.ts       0.16 KiB
 - obj/js-component-bindgen-component.js         10.1 KiB


> build:wasm-tools
> npm run build:component:wasm-tools && npm run build:transpile:wasm-tools


> build:component:wasm-tools
> ./jco.sh new target/wasm32-unknown-unknown/release/wasm_tools_js.wasm -o obj/wasm-tools.wasm


> build:transpile:wasm-tools
> ./jco.sh transpile obj/wasm-tools.wasm --map console=../lib/console.js --out-dir obj


Transpiled JS Component Files:

 - obj/exports/exports.d.ts  1.36 KiB
 - obj/imports/console.d.ts  0.07 KiB
 - obj/wasm-tools.core.wasm  5.72 MiB
 - obj/wasm-tools.d.ts       0.16 KiB
 - obj/wasm-tools.js         22.6 KiB

ncc: Version 0.36.1
ncc: Compiling file index.js into ESM
    0kB  dist-cli/package.json
 1416kB  dist-cli/index.js
 4719kB  dist-cli/js-component-bindgen-component.core.wasm
 5853kB  dist-cli/wasm-tools.core.wasm
 6391kB  dist-cli/wasm2js
 7787kB  dist-cli/wasm-opt
26166kB  [2527ms] - ncc 0.36.1
ncc: Version 0.36.1
ncc: Compiling file index.js into ESM
    0kB  dist-api/package.json
   99kB  dist-api/wasi_snapshot_preview1.reactor.wasm
   99kB  dist-api/wasi_snapshot_preview1.command.wasm
 1303kB  dist-api/index.js
 4719kB  dist-api/js-component-bindgen-component.core.wasm
 5853kB  dist-api/wasm-tools.core.wasm
 6391kB  dist-api/wasm2js
 7787kB  dist-api/wasm-opt
26251kB  [2125ms] - ncc 0.36.1
rm: cannot remove 'dist': No such file or directory

$ ./jco.sh transpile -o dist ./test/fixtures/records.component.wasm
(jco transpile) ComponentError: failed to parse the input component

Caused by:
    missing component instantiation argument named `import-type-f1` (at offset 0xca87)
    at generate (file:///home/danielbevenius/work/wasm/tmp/jco/node_modules/@bytecodealliance/jco/cli.mjs:43508:13)
    at transpileComponent (file:///home/danielbevenius/work/wasm/tmp/jco/node_modules/@bytecodealliance/jco/cli.mjs:44561:37)
    at transpile (file:///home/danielbevenius/work/wasm/tmp/jco/node_modules/@bytecodealliance/jco/cli.mjs:44480:27)
    at async file:///home/danielbevenius/work/wasm/tmp/jco/node_modules/@bytecodealliance/jco/cli.mjs:45243:9

I don't have jco installed as a global:

$ npm list -g
/home/danielbevenius/.nvm/versions/node/v18.14.0/lib
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

But like you mentioned the versions do differ:

$ ./jco.sh --version
0.5.5
$ node src/jco.js --version
0.6.1

Looking into this some more I noticed that package.json contains a devDependency as follows:

   "devDependencies": {
     "@bytecodealliance/componentize-js": "0.0.5",
     "@bytecodealliance/jco": "^0.5.2",
    ...
   }

And if I'm not mistaken the npm caret rules doesn't apply in the same way as for released versions, and hence this dependency is not getting updated to 0.6.1 but still only on 0.5.5 which is the latest patch release. Perhaps this should be updated to:

"@bytecodealliance/jco": "^0.6.1"

My original issue was that I was using ^0.5.5 and also ran into this issue not getting the later minor update to 0.6.1. Changing this to 0.6.1 things worked perfectly.

from jco.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.