Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Disable hash for release builds #136

Closed
nalply opened this issue Feb 27, 2021 · 7 comments · Fixed by #354
Closed

Disable hash for release builds #136

nalply opened this issue Feb 27, 2021 · 7 comments · Fixed by #354
Labels
assets Build pipelines for specific asset types cli Trunk CLI application enhancement New feature or request ready Ready to be implemented

Comments

@nalply
Copy link

nalply commented Feb 27, 2021

Hashes are useful for cache busting, I grant that.

But for release builds they aren't really neccessary, or are they?

Would it make sense to disable hashes for release builds?

@philip-peterson
Copy link
Contributor

Thanks for reporting. Curious, is there a particular use-case you have for removing the hash?

This functionality is also requested by #46 so I am not contesting its usefulness.

@nalply
Copy link
Author

nalply commented Feb 28, 2021

It's more a nice to have.

I plan to embed the generated files into an executable with include_str! and it would be easier if the files didn't have hashes.

@thedodd
Copy link
Member

thedodd commented Mar 5, 2021

@nalply as @philip-peterson said, thanks for the report. I would assert that hashing the content for release builds is actually what is MOST critical, because that is what will ensure that your users content is properly E-tagged (if using etags), and the old cached versions of files are not used because the hash in the file changes its identity with respect to the cache. So cache busting is definitely critical for production / release builds.

That said, what you are looking for actually reminds me a bit of what we've discussed over in #9, namely the bits about generating a manifest of all objects which were output from the build. That would give you a mechanism for being able to programatically including the contents of the generated content without having to do anything hacky.

Thoughts?

@thedodd
Copy link
Member

thedodd commented Mar 24, 2021

@nalply definitely let me know if we need to open this issue again.

@thedodd thedodd closed this as completed Mar 24, 2021
@fosskers
Copy link

Release builds aside, I have hit a case where building without hashes may be necessary for use with https://github.com/w3reality/wasm-mt/ . Their setup cites a first step as:

use wasm_mt::prelude::*;

let pkg_js = "./pkg/exec.js"; // path to `wasm-bindgen`'s JS binding
let mt = WasmMt::new(pkg_js).and_init().await.unwrap();

In the case of trunk, the exec.js is the dist/index-<longhashhere>.js file. But a usable filename can't be written there in our case, since doing so would invalidate the hash of the very file we're trying reference. So it seems to me that being able to produce build artifacts without hashes is the only way forward (well, short of foregoing trunk and using raw wasm-pack...)

Thoughts?

@thedodd thedodd reopened this Jul 12, 2021
@thedodd
Copy link
Member

thedodd commented Jul 12, 2021

@fosskers well, that sounds like reason enough to add a CLI or Trunk.toml config option to disable hashing of filenames. This will be a rather simple feature to implement as the hashing of contents is pretty well encapsulated the plumbing for configuration is quite good.

Let's do it.

@thedodd thedodd added assets Build pipelines for specific asset types cli Trunk CLI application enhancement New feature or request ready Ready to be implemented labels Jul 12, 2021
@fosskers
Copy link

Thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
assets Build pipelines for specific asset types cli Trunk CLI application enhancement New feature or request ready Ready to be implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants