Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Document wasmpack/webpack configuration behaviour for building Rust #771

Closed
shalzz opened this issue Oct 9, 2019 · 13 comments
Closed

Document wasmpack/webpack configuration behaviour for building Rust #771

shalzz opened this issue Oct 9, 2019 · 13 comments

Comments

@shalzz
Copy link

shalzz commented Oct 9, 2019

💡 Feature request

Overview and problem statement

#724 only documented custom webpack behaviour, in lieu of that also document how a rust wasm module is built and packaged for cloudflare workers.
This will allow people to combine custom webpack configuration with wasm builds.

Basic example

For example having both typescript and rust in the same worker.

@samuelcolvin
Copy link

Any progress on this? It would be great.

If I want to use webpack and rust in the same worker, am I best to use the webpack loader for wasm or do something else?

@EverlastingBugstopper
Copy link
Contributor

👋 - hi, we don't have plans on prioritizing documenting this functionality at the moment. that being said, I believe this npm module may help with what you're looking to do.

@EverlastingBugstopper
Copy link
Contributor

this tool also demonstrates how to create a hybrid project

@shalzz
Copy link
Author

shalzz commented Jun 15, 2020

@EverlastingBugstopper Yes using wasm-pack-plugin allows achieving the required functionality.

However setting type = "webpack" in wrangler.toml and a custom webpack with the above plugin does results in a wasm module being built but not being uploaded to cloudflare worker.

The wasm module gets uploaded only when type= rust or similar. This means we have to rely on hacks to make sure the final artifacts result in the correct directory and filename, etc that are prone to changes with newer wrangler version.

The only reasonable solution I see in the long term is allowing the use of webpack_config with type=rust as well. (The user has to make sure to have the wasm pack plugin)

@EverlastingBugstopper
Copy link
Contributor

cc @xtuc

@samuelcolvin
Copy link

samuelcolvin commented Jun 19, 2020

@shalzz what hacks are you using to get this to work? ignore see below.

@samuelcolvin
Copy link

Cancel that, I have it working. I don't know what hacks @shalzz was referring to, I've played around with this a lot and didn't find any hacks I had to implement to get workers to work with wasm-pack-plugin. The only negative change I saw was that I now get the warning

✨  Built successfully, built project size is 1 MiB. ⚠️  Your built project has grown past the 1MiB size limit and may fail to deploy. ⚠️ 

But the size hasn't actually changed - I assume the warning was just muted for type = "rust" projects as the size always exceeds 1MB?

It's working here in case it helps anyone.

This change also fixed this bug which I asked about on the community forum but never got any help with.

@stale
Copy link

stale bot commented Aug 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 21, 2020
@shalzz
Copy link
Author

shalzz commented Aug 24, 2020

Hi, are there no plans to work on this?

@stale stale bot removed the wontfix label Aug 24, 2020
@ashleymichal
Copy link
Contributor

ashleymichal commented Sep 11, 2020

hey @shalzz !

sorry for the dead air. if i understand correctly, the ask is for a more flexible approach which would support both a rust wasm module and typescript in the worker. I think that's a great goal; we don't have cycles in the near term for this, however I do want to keep it in the issue tracker.

@shalzz
Copy link
Author

shalzz commented Sep 11, 2020

Wow! Thank you. I'm honored.

@stale
Copy link

stale bot commented Sep 19, 2021

This issue has been automatically marked as stale because it has not had recent activity in the last 180 days. It will be closed if no further activity occurs in the next week. Please feel free to comment if you'd like it to remain open, and thank you for your contributions.

@stale stale bot added the timed out label Sep 19, 2021
@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically closed because it has not had recent activity. You may re-open the issue if it is still relevant.

@stale stale bot closed this as completed Jan 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants