-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Tracking issue for Parcel compatibility #182
Comments
Thanks for the report! I think this is similar to #154 in that parcel doesn't have enough support for wasm at the moment to get this natively working (unfortunately) |
Hm although actually I'm gonna leave this open to track parcel support! |
I've made a plugin to solve this issue. It works for me. (Currently the package name is |
@catsigma where is the source located? I don't see a repo link from the npm page |
@catsigma this is a nice start! For us to promote the plugin, I think we would want:
|
@fitzgen thanks, I'll mod the plugin according to your tips. |
@catsigma this looks great, can we rename the plugin to let me know if you need any help. |
@sendilkumarn |
@sendilkumarn the name And it supports both |
@catsigma a great work, thanks 👍 |
@sendilkumarn
Great! Thank you for telling me.
Sunday, September 23, 2018, 19:11 +0800 from notifications@github.com <notifications@github.com>:
…
|
I'm gonna close this in favor of https://github.com/rustwasm/rust-parcel-template now, new issues should go there! |
This issue should be re-opened as parcel doesn't work with the generated stub and the way rust-parcel-template works doesn't allow for using the typescript typings. |
@0xcaff hello! What problem do you have exactly? And could you clarify what do you mean by "doesn't allow for using the typescript typing"? I didn't work with typescript, but my JS project works great at the moment. Would be glad to help! |
Hey @mvlabat ! When using rust-parcel-template, with an import like the following:
typescript doesn't know the type of Usually, you can tell typescript to use certain types for a module with ambient module declarations, but ambient module declarations don't seem to work with relative paths. wasm-bindgen already generates the typings, but typescript needs to be told about them outside of the build step so development tools work. The way that probably fits this use case best is building with |
@0xcaff, for now there is a work-around I found.
declare module "*.toml" {
const value: typeof import('../crate/pkg/rust_parcel');
export default value;
}
|
@skyne98, what do you mean by this?
I'm having the same problem, hoping to resolve! When I add the import wasm from "../crate/Cargo.toml"
|
God, this was terrible to figure out. Parcel is lovely and magical, but its module resolution was a bit too magical for TypeScript. In `index.ts`, Parcel references the Rust crate by importing the `Cargo.toml` file: ```ts import wasm from "../crate/Cargo.toml" ``` Parcel understands this, but TypeScript doesn't and freaks out: ``` src/index.ts:2:18 - error TS2792: Cannot find module '../crate/Cargo.toml'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? ``` I mean, no I didn't, but thanks for trying. Anyways, there are two issues: - TS can't resolve the import _at all_ because it can't handle non-JS - TS _definitely_ can't see the typings generated by wasm-bindgen I played around with many permutations of `tsconfig.json` options, ranging from `files`, `include`, `baseUrl`, `paths`, and so on. None of them proved very helpful. In the end, here is what worked: 1. Heeding [this comment](rustwasm/wasm-bindgen#182 (comment)), define a wildcard module declaration (TS's way of handling non-JS loaders) and use `typeof` to infer the types produced by wasm-bindgen ```ts declare module "*.toml" { const value: typeof import("../crate/pkg/rust_parcel") export default value } ``` 2. Import `index.d.ts` at the top of `index.ts`, as a dependency for the `Cargo.toml` import: ```ts /// <reference path="./index.d.ts" /> import wasm from "../crate/Cargo.toml" ``` I needed both steps 1 and 2 to get it to work. Step 1 alone works if your `tsconfig.json` uses the `files` property, but it doesn't work if you use `includes` with the same argument. ```json { "files": [ "./src/index.d.ts", "./src/index.ts" ] } ``` Anyways, I now know more than I ever wanted to know about TypeScript.
Hi! This is not a bug report (for now I think there isn't any), but just a support request. I wasn't sure it was right to open the issue in this repository, but it seems to me that here I have more chances to get some help. )
I'm trying to get "greet" example (from readme) working with Parcel.
On Rust side everything is compiled successfully. I run
wasm-bindgen target/wasm32-unknown-unknown/debug/js_hello_world.wasm --out-dir .
command and then import the generated js file like this:After that I run parcel to build everything as is. But when opening the page in browser I get the following error in console:
Parcel expects
js_hello_world_bg
file to havejs
extension, but notwasm
. Modifyingimport
statement appendingwasm
to the module path fixes the error, but then I get another one:I don't know how to fix this one. I would be grateful for any help. Thank you!
The text was updated successfully, but these errors were encountered: