This changelog follows the patterns described here: https://keepachangelog.com/en/1.0.0/.
Subheadings to categorize changes are added, changed, deprecated, removed, fixed, security
.
- Added the
--address
option fortrunk serve
. - Open autoreload websocket using wss when assets are served over a secure connection.
- Added the
data-type
attribute to Rust assets. Can be set to eithermain
(previous behaviour and default) orworker
, which builds the asset and includes it as a web worker. - Added the
--proxy-insecure
option fortrunk serve
. - Added the
insecure
option to theproxy
section inTrunk.toml
.
- Bump notify to 5.0.0-pre.13, which fixes notify-rs/notify#356
- Remove the temporary output of the SASS compiler from the output directory of Trunk.
- The
cargo serve
command now listens on127.0.0.1
(localhost) instead of0.0.0.0
, fixing security issues when on a public Wi-Fi or otherwise accessible network connection. The address can still be changed with theTrunk.toml
or--address
cli argument. - Force HTTP/1 on proxy client, which fixes #280
- Print the serving address with a protocol to make it to be recognized as an URL in some terminals #292
- Verify the target architecture when downloading tools in addition to the OS and fail if the architecture doesn't match.
- Trunk now includes a hooks system. This improves many use cases where another build tool is needed alongside trunk, by allowing trunk to be configured to call them at various stages during the build pipeline. It is configured under
[[hooks]]
inTrunk.toml
. More information can be found in the Assets section of the docs. - Added
trunk serve
autoreload triggered over websocket that reloads the page when a change is detected. The--no-autoreload
flag disables this feature. - Added the optional
pattern_script
field to theTrunk.toml
for overloading the template of initialization script. - Added the optional
pattern_preload
field to theTrunk.toml
for overloading the template of WASM preloading. - Added the optional
pattern_params
field to theTrunk.toml
for extendingpattern_script
andpattern_preload
with additional values, including external files. Overloading these parameters allow users to usetrunk
with other frameworks like this. - Allow overriding the used tool versions (wasm-bindgen, wasm-opt, dart-sass) with environment variables. For example use
TRUNK_TOOLS_SASS
to override the used dart-sass version.
- Download and use the official
dart-sass
binary for SASS/SCSS to CSS compilation. This allows to always support the latest features and will allow to make Trunk available for futher platforms in the future as this removes the dependency onsass-rs
. - Proxied websockets now shut down immediately upon completion of streaming data in either direction, instead of waiting for completion of both directions.
- Updated all dependencies to their latest versions, fixing several potential security issues.
- Fixed #219: Preserve websocket message types when sending to the backend.
- Trunk has been fully cut over to [email protected].
- As part of the Tokio cut over, the Trunk network stack is now fully based on Axum.
- All download utilities have been made fully async. This will likely help us in the future as we continue to leverage this functionality more and more.
- Added a new CLI option
trunk clean -t/--tools
which will optionally clean/remove any cached tools used by Trunk, such aswasm-bindgen
&wasm-opt
. This may be useful if there are ever issues with old tools which need to be removed. - Fixed #198 which was a long-standing issue with the static file server. In essence, Trunk will now check the
accept
header of anyGET
request matching the static file server, and if the requested asset does not exist and theaccept
header allows either*/*
ortext/html
, then return theindex.html
.- This is expected functionality for SPAs which are using client side routing.
- This reduces the friction which has often been observed with Trunk where a user is expecting a 404 to be served when requesting a static image, CSS, or some other asset. With this update, 404s will now be returned as expected, and the
index.html
should only be returned for applicable cases.
- Added a new
proxy
example which demonstrates all functionality of the Trunk proxy system. - Fixed #209 where the default Rust App pipeline was causing wasm-opt to be used even for debug builds when the Rust App HTML link was being omitted.
- Closed #168: RSS feed for blog.
- Isolated code used for version checking & formatting of version output for downloadable applications (wasm-bindgen & wasm-opt). Added unit tests to cover this logic.
- Fixed #197 & #175 where disabling wasm-opt for debug builds while keeping it enable for release builds was not possible without some hacking. Now, wasm-opt will only be used for release builds and only when enabled. This semantically matches cargo's behavior with optimizations in release mode.
- When wasm-opt level is not set explicitly, do not invoke it at all for debug builds, and for release builds invoke with default optimization level.
- Closed #139: Download and manage external applications (namely
wasm-bindgen
andwasm-opt
) automatically. If available in the right version, system installed binaries are used but if absent the right version is downloaded and installed. This allows to use trunk without the extra steps of downloading the needed binaries manually. - Added an example application for using Trunk with a vanilla (no frameworks) Rust application.
wasm-opt
is now enabled by default (with default optimization level) as the binary is automatically downloaded and installed by trunk. It can still be disabled by settingdata-wasm-opt
to0
.
- Closed #158: Support for inlining SASS/SCSS after compilation using the new
data-inline
attribute. - Closed #145: Preloading of the WASM and JS files are now added to the
<head>
element. This ensures that the code starts downloading as soon as possible, and can make your app start up a few seconds earlier on a slow network. - Closed #135: Allow users to specify
data-keep-debug
&data-no-mangle
options on Rust build pipelines, which influence their correspondingwasm-bindgen
CLI options. - Added an example application for using Trunk with a vanilla (no frameworks) Rust application.
- Fixed #148: any changes detected under a
.git
path are now being ignored by default. - Fixed #163: allow using
copy-file
assets on files which do not have a file extension. - Fixed #60: Added
data-cargo-features
attribute for rust asset type.
- Completely removed
indicatif
from the code base, and now we are using thetracing
crate. This has greatly simplified the code base. Only downside ... no more progress spinner. Per a fair bit of demand however, cargo output and output from other subprocess calls are now piped directly to stdout/stderr for better visibility into what is happening behind the scenes.
- Fixed a bug where build pipeline errors were being hidden/masked on subsequent builds.
- Fixed a bug related to the watch system, which would cause build loops if there was an error on the initial build.
Added support for proxying WebSockets. This was a long-standing feature request. Due to changes upstream in the async-std/tide ecosystem, we are now able to properly support this. This will also unlock some nice features such as HMR via WebSockets, and other such niceties.
- Added the
--proxy-ws
CLI option for enabling WebSocket proxying on a CLI defined proxy. - Added the
ws = true
field to theTrunk.toml
[[proxy]]
sections which will enable WebSocket proxying for proxies defined in theTrunk.toml
. - WASM files are now automatically optimized with
wasm-opt
to reduce the binary size. The optimization level can be set with the newdata-wasm-opt
argument of therust
asset link andwasm-opt
binary is now required to be globally installed on the system when being used. E.G.,<link data-trunk rel="rust" [...] data-wasm-opt="4"/>
.
- Closed #81: this is no longer needed as we now have support for WebSockets. HTTP2 is still outstanding, but that will not be a blocker for use from the web.
- Closed #95: fixed via a few small changes to precedence in routing.
- Closed #53: we've now implemented support for proxying WebSockets.
- Fixed #133 where
watch
was infinitely looping on Windows because the canonicalization path didn't match the un-canonicalized ignore list.
- Fixed #124 where path canonicalization was being performed on a path which did not yet exist, and as it turns out was already in canonical form.
- Closed #93: The
watch
andserve
subcommands can now watch specific folder(s) or file(s) through the new--watch <path>...
option. Thanks to @malobre for all of the work on this one. - Inline the content of files directly into
index.html
with the newinline
asset. There are three content types that can be inlined:html
,css
, andjs
. The type can be specified with thetype
attribute or is inferred by the file extension.
- Closed #49: old artifacts in the dist dir are now being cleaned-up as new builds successfully complete. Thanks @philip-peterson & @hamza1311 for their work on this one.
- Fixed infinite rebuild loop on Windows started by
watch
command by path canonicalizing in the ignored paths resolver.
- Fixed a regression in Trunk CLI help output, where incorrect help info was being displayed.
- Closed #82: Remove the hardcoded Unix (
/
) path separator from the code and convert Windows NT UNC path to its simplified alternative before passing tocargo metadata
command to prevent issues with Rust package collisions and writingindex.html
file. - Updated the
WatchSystem
to use{:?}
debug formatting for errors to ensure that full error chains are reported. This impacts thewatch
&serve
subcommands. Thebuild
command was already behaving as needed.
- Closed #78: Ensure all asset pipelines are properly rooted to the configured
public-url
, which defaults to/
.
- Closed #76: Ensure canonical paths are used for pertinent paths in the runtime config to ensure watch config is able to properly ignore the dist dir and such.
- Made a lot of refactoring progress to be able to support #28 & #46. More work remains to be done, but the foundation to be able to knock these items out is now in place.
- All assets which are to be processed by trunk must now be declared as HTML
link
elements as such:<link data-trunk rel="rust|sass|css|icon|copy-file|..." data-attr0 data-attr1/>
. The links may appear anywhere in the HTML and Trunk will process them and replace them or delete them based on the associated pipeline's output. If the link element does not have thedata-trunk
attribute, it will not be processed.
- Fixed #50: the ability to copy a file or an entire dir into the dist dir is now supported with two different pipeline types:
<link data-trunk rel="copy-file" href="target/file"/>
and<link data-trunk rel="copy-dir" href="target/dir"/>
respectively.
- The
manifest-path
option has been removed from all Trunk subcommands. The path to theCargo.toml
is now specified in the source HTML as<link rel="rust" href="path/to/Cargo.toml"/>
. Thehref="..."
attribute may be omitted, in which case Trunk will look for aCargo.toml
within the same directory as the source HTML. If thehref
attribute points to a directory, Trunk will look for theCargo.toml
file in that directory.
- Closed #59: Support for writing the public URL (
--public-url
) to the HTML output.
- Closed #62: Improved handling of file paths declared in the source
index.html
to avoid issues on Windows. - Closed #58: The output WASM file generated from the cargo build is now determined purely based on a JSON build plan provided from cargo itself. This will help to provide a more stable pattern for finding build artifacts. If you were running into issues where Trunk was not able to find the WASM file built from cargo due to hyphens or underscores in the name, that problem should now be a thing of the past.
- The default location of the
dist
dir has been slightly modified. Thedist
dir will now default to being generated in the parent dir of cargo'starget
dir. This helps to make behavior a bit more consistent when executing trunk for locations other than the CWD. - Fixed an issue where paths declared in a
Trunk.toml
file were not being treated as relative to the file itself.
- Closes #55: Fixed a regression in the server where the middleware was declared after the handler, and was thus not working as needed. Putting the middleware first fixes the issue.
- Added support for proxying requests to arbitrary HTTP backends.
- This includes a basic CLI based config.
- This also includes a more robust
Trunk.toml
config which allows for specifying multiple proxies.
- Added a
trunk config show
subcommand. This command will pretty-print Trunk's final runtime config based on any config file & env vars. This can be useful for debugging & testing.
- In addition to CLI arguments and options, Trunk now supports layered configuration via
Trunk.toml
& environment variables. - Added an example
Trunk.toml
to the root of the repository showing all possible config values along with their defaults.
- README has been updated with details on how the config system works.
- Removed a fair amount of code duplication as part of the configuration changes.
- Added full release automation with optimized release binaries for Linux, MacOS & Windows (all x64). Brew packages for MacOS and Linux, and a Chocolatey package for Windows coming soon.
- Closed #37: Trunk now exits with a non-zero code when an error takes place during execution.
- Closed #40: Trunk is now copying JS snippets from wasm-bindgen into the dist dir as part of the standard build/watch/serve commands.
- Fixed a regression in resolving
cargo build
's output WASM.
- Handle multi-project & workspace contexts. Thank you @oli-obk for developing cargo_metadata.
- All CLI output has been improved using console & indicatif. Builds, asset pipelines, and the like are using a progress spinner along with messages. All in all this provides a much more clean CLI output experience.
- Using
console::Emoji
to ensure that emojis are only sent to stdout/stderr when supported. - All builds performed by trunk now emit warnings when a link is found in the HTML which is an invalid FS path. This does not effect hyperlinks of course.
trunk serve
now takes the--open
option to control whether or not a browser tab will be opened. Thanks @MartinKavik for the report.- The
trunk serve
listener info has been slightly updated. It continues to function as in previous releases. Thanks @MartinKavik for the report.
- Closed #15: ensure cargo package name is processed as cargo itself processes package names (
s/-/_/
). - Closed #16: default to
index.html
as the default target for all CLI commands which expect a target. This matches the expectation of Seed & Yew.
Thanks @MartinKavik for reporting these items.
- Swap our
grass
forsass-rs
. - Compress SASS/SCSS output when building in
--release
mode.
- Fix an issue with the watch system which was breaking builds on Windows.
- Initialize release. See the release notes on Github for more info.