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

Support vendoring modules which read "static" files, like .wasm #14123

Closed
GJZwiers opened this issue Mar 25, 2022 · 9 comments
Closed

Support vendoring modules which read "static" files, like .wasm #14123

GJZwiers opened this issue Mar 25, 2022 · 9 comments
Labels
suggestion suggestions for new features (yet to be agreed) vendor related to the vendor subcommand

Comments

@GJZwiers
Copy link
Contributor

I would like to deno vendor a module that uses WebAssembly (WASM). It is compiled using wasm-bindgen so there is a directory structure like this:

pkg/
├── file.js
├── file_bg.wasm
├── file.d.ts

The .js file contains glue code that calls into the .wasm file. It is vendored successfully but tries to fetch the WASM from a URL like this:

input = new URL('file_bg.wasm', import.meta.url);

Unfortunately, after vendoring the URL points to a path in the local filesystem, but nothing is there because the .wasm file isn't brought over. So it is not possible to run the module locally after vendoring.

@kitsonk kitsonk added suggestion suggestions for new features (yet to be agreed) vendor related to the vendor subcommand labels Mar 27, 2022
@kitsonk
Copy link
Contributor

kitsonk commented Mar 27, 2022

Hmmm... vendoring remote modules that read "static" files would be complex, but I can see the need.

@dsherret thoughts?

@kitsonk kitsonk changed the title Vendored module does not run, because it depends on a .wasm file Support vendoring modules which read "static" files, like .wasm Mar 27, 2022
@mlafeldt
Copy link
Contributor

Noticed this problem today when trying to vendor eszip:

❯ deno vendor https://deno.land/x/[email protected]/mod.ts
Vendored 3 modules into vendor/ directory.

To use vendored modules, specify the `--import-map` flag when invoking deno subcommands:
  deno run -A --import-map vendor/import_map.json main.ts

❯ tree vendor/
vendor/
├── deno.land
│   └── x
│       └── [email protected]
│           ├── eszip_wasm.generated.js
│           ├── loader.ts
│           └── mod.ts
└── import_map.json

3 directories, 4 files

Since https://deno.land/x/[email protected]/eszip_wasm_bg.wasm isn't downloaded, the vendored version of eszip is broken.

@bartlomieju
Copy link
Member

I believe this will have to wait for #2552

@CreatCodeBuild
Copy link

Any update on this?

@petamoriken
Copy link
Contributor

I believe we need to wait for Import Attributions (a.k.a Import Assertions).

@GJZwiers GJZwiers closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2023
@dsherret dsherret reopened this Apr 26, 2023
@dsherret
Copy link
Member

Actually, yeah this would be supported by #2552. For now, this can be solved by manually running a custom post-vendoring step to download the necessary .wasm files.

@serhalp
Copy link

serhalp commented Dec 17, 2024

@dsherret now that #26668 has landed, can we reopen this issue? 👀

@dsherret
Copy link
Member

I don't think there's anything actionable in this issue. With Wasm modules this now works, but they need to be imported using Wasm imports.

For static files, follow #25354

@serhalp
Copy link

serhalp commented Dec 17, 2024

@dsherret Ah, my bad — you're saying that when WASM support landed, WASM vendoring support landed too? In that case, carry on :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions for new features (yet to be agreed) vendor related to the vendor subcommand
Projects
None yet
Development

No branches or pull requests

8 participants