ComponentizeJS icon indicating copy to clipboard operation
ComponentizeJS copied to clipboard

Reference packages to import

Open wst24365888 opened this issue 1 year ago • 2 comments

First of all, thanks for this awesome project.

I'm wondering if I can reference packages to import like cargo component for ComponentizeJS (and also for componentize-py but not tested yet).

The project structure looks like this. The wit package foo is implemented in another project, and I will combine the implementation component with this component together using wasm-tools later.

$ tree -I node_modules
.
├── package.json
├── pnpm-lock.yaml
├── source.js
└── wit
    ├── cli/
    ├── clocks/
    ├── filesystem/
    ├── foo
    │   ├── bar.wit
    │   └── world.wit
    ├── http/
    ├── io/
    ├── random/
    ├── sockets/
    └── world.wit

But it seems that I can't use jco and ComponentizeJS to accomplish this task..

(jco componentize) ComponentError: package not found
     --> //?/C:/Users/<USER_NAME>/Desktop/componentized-js-test/wit/world.wit:4:10
      |
    4 |   import wasi:foo/[email protected];
      |          ^-------
    at spliceBindings (file:///C:/Users/<USER_NAME>/AppData/Local/pnpm/global/5/.pnpm/@[email protected]/node_modules/@bytecodealliance/componentize-js/lib/spidermonkey-embedding-splicer.js:3800:11)
    at componentize (file:///C:/Users/<USER_NAME>/AppData/Local/pnpm/global/5/.pnpm/@[email protected]/node_modules/@bytecodealliance/componentize-js/src/componentize.js:50:64)
    at async componentize (file:///C:/Users/<USER_NAME>/AppData/Local/pnpm/global/5/.pnpm/@[email protected]/node_modules/@bytecodealliance/jco/src/cmd/componentize.js:15:25)
    at async file:///C:/Users/<USER_NAME>/AppData/Local/pnpm/global/5/.pnpm/@[email protected]/node_modules/@bytecodealliance/jco/src/jco.js:186:9

To reproduce, please head over to this repo.

wst24365888 avatar May 17 '24 08:05 wst24365888

You need to restructure your WIT folder to contain a deps subfolder. Something like:

cd wit
mkdir deps
mv * deps/
mv deps/world.wit .

guybedford avatar May 21 '24 19:05 guybedford

I was clued in to "deps" when I stumbled upon the wit-deps repo. This issue is the sole place I've been able to find a pointer about how to use them. Is there a canonical place to go to read more about how deps are supposed to be resolved?

cdata avatar May 24 '24 05:05 cdata