rust-webpack-template icon indicating copy to clipboard operation
rust-webpack-template copied to clipboard

`npm run start` compiles crate in "dev" profile by default

Open bantic opened this issue 6 years ago • 3 comments

Describe the Bug

npm run start uses the WasmPackPlugin to compile the associated crate, and that plugin compiles in "dev" profile by default. This wasn't obvious (to me), and it seems that it contravenes other documentation in the wasm-pack book that indicates that wasm-pack build defaults to "release" profile.

As a result, I found it very confusing when profiling the (slow vs js) performance of a fairly simple wasm module that I had built and was running from this template.

Steps to Reproduce

  1. npm init rust-webpack my-app
  2. cd my-app
  3. npm run start
  4. Crate is compiled in dev profile, but there is no indication in the README, webpack.config.js, or the terminal that this is so.

Expected Behavior

I was expecting that the crate would be compiled in "release" profile, since the wasm-pack documentation says that that is its default.

Actual Behavior

The crate is is compiled in "dev" profile.

bantic avatar Mar 04 '19 16:03 bantic

I made a PR (#117) to add some info to the webpack config that would have helped me. If it would be useful, I'd be happy to make a follow-up PR to modify the README to point this out, or take a stab at modifying the command-line output to add "in X profile" to the Compiling your crate... message.

bantic avatar Mar 04 '19 16:03 bantic

It would be great if you can change the compilation message to indicate the env, :+1:

You can find it here https://github.com/wasm-tool/wasm-pack-plugin/blob/b26fc434ef8c87b7807a0ddd68fae962c0b37ae0/plugin.js#L70

xtuc avatar Mar 04 '19 16:03 xtuc

@xtuc Thanks! Added a PR for the wasm-pack-plugin: https://github.com/wasm-tool/wasm-pack-plugin/pull/54

bantic avatar Mar 06 '19 17:03 bantic