-
Notifications
You must be signed in to change notification settings - Fork 8
refactor!: overhaul DevServer and Dist APIs, add Hook and Transformer traits #78
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
Merged
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
ca28128
Clippy: fix indentation in doc comments
yozhgoor e103a8c
Deprecate `default_dist_dir` in favor of `default_dir_dir_debug` and …
yozhgoor b921f1d
Deprecate `run_in_workspace` in favor of `use_workspace_root` and `us…
yozhgoor fcb54d5
Add missing logger initialization in example
yozhgoor 43a5173
Change `command` and `arg`/`args` implementation
yozhgoor 77cdd86
Remove deprecated functions
yozhgoor 435d476
self-review
yozhgoor 0be34c7
Update `README.md`
yozhgoor af672b2
Fix CI
yozhgoor b870cb3
Clean up documentation
yozhgoor b0a49ab
Fix intra doc links
yozhgoor 56339f1
Remove `run_in_workspace` from `Dist`
yozhgoor 943c9fb
Change `dist_dir_path` into `dist_dir`
yozhgoor 7f6aea1
Add a `xtask` method to `DevServer`
yozhgoor e64f724
Change `dist_dir_path` into `dist_dir` in `dist.rs` too
yozhgoor 982f040
Rename `Dist::run` into `Dist::build`
yozhgoor 1b6dbb9
Update `README.md`
yozhgoor ef26784
Change `static_dir_path` into `assets_dir`
yozhgoor f667a80
Rename `static` directory into `assets` in `examples/demo`
yozhgoor 04ea1f9
Improve module documentation for DevServer
yozhgoor 5832a26
Move `default_dist_dir_debug` and `default_dist_dir_release` as assoc…
yozhgoor 0cce0a1
Add the `env` and `envs` methods on `DevServer`
yozhgoor b290c21
Add `pre` and `post` methods on `DevServer`
yozhgoor 60063ed
Clean up
yozhgoor bcf09c8
Self review
yozhgoor 75e6cab
Fix intra doc links for `DevServer`
yozhgoor 00cc06a
Use package root instead of workspace root for the assets directory
yozhgoor f19c18a
`arg`/`args` and `env`/`envs` now return an error if no command avail…
yozhgoor 35b37ad
Clippy
yozhgoor 059254a
`DevServer`: fix doc about `watch` and error propagation
yozhgoor e06ce35
Add a `post` method on `DevServer`
yozhgoor 2d8f042
Fix doc comments and update `README.md`
yozhgoor 01da9d1
fix(sass): move create_dir_all after file check and guard dest.parent()
Copilot 3fc2ed0
Fix doc comment placement on `sass_options`
cecton 40a0ac6
Return `Utf8PathBuf` from `default_debug_dir` and `default_release_dir`
cecton a9470da
Rename `DevServer::not_found` to `not_found_path`
cecton ee1abae
Replace cfg macros with inline `#[cfg(...)]` attributes
cecton eabfb85
Change `DevServer::command` to accept `process::Command`
cecton 2174586
Restore `arg`/`args`/`env`/`envs`, add `cargo`, change panics
cecton 1ba3931
Fix auto-discovery default directory from `public` to `assets`
cecton cda5fc1
Add "Why xtask-wasm?" section to README and crate docs
cecton 661ce08
Add `pres`/`posts` to DevServer for adding multiple pre/post commands…
cecton 66c0f5b
Introduce `Processor` trait for pre/post commands
cecton b08c640
Rename `pre_commands`/`post_commands` to `pre_processors`/`post_proce…
cecton 628952a
Document the `Processor` trait in README and crate-level docs
cecton f1627c7
Rename `Processor`/`pre_processors`/`post_processors` to `Hook`/`pre_…
cecton f891195
Add `Transformer` trait to `Dist` for extensible asset processing
cecton 04d95d3
Update docs: Processor -> Hook, document Transformer and SassTransformer
cecton 1384510
Move SassTransformer into its own src/sass.rs module
cecton 3db53b9
Make SassTransformer opt-in rather than seeded in Dist::default
cecton a284a22
docs(Hook): replace DevServer::default() with idiomatic clap-parsed e…
cecton 2f22b8c
docs(Transformer): replace Dist::default() with idiomatic clap-parsed…
cecton 0e0d902
docs(SassTransformer): replace Dist::default() with idiomatic clap-pa…
cecton 5c46359
fix(SassTransformer): propagate SASS compilation error instead of pan…
cecton 1b9c0e6
docs(DevServer): improve watch field doc comment
cecton 3ead5ac
feat(Dist): add optimize_wasm() builder to integrate WasmOpt into the…
cecton b7e192d
fix(Dist): skip wasm-opt for debug builds
cecton 7596501
fix(Dist): propagate transformer errors in copy_assets
cecton 1b11aaf
fix(Dist): always bail when assets directory does not exist
cecton 45a446d
fix(Dist): remove unused SassTransformer import in dist.rs
cecton c493b80
fix(Dist): skip assets copy gracefully when directory does not exist
cecton f924336
Fix small issue in run_example
cecton 68c34f5
docs: add CHANGELOG.md and link it from README and crate docs
cecton 738b589
chore: include CHANGELOG.md in published crate
cecton ca12cb3
feat(WasmOpt): derive Debug
cecton face315
fix(docs): mark wasm-opt doc-test as ignored (requires wasm-opt feature)
cecton c083be1
clippy
cecton a8b191d
feat: derive Debug on Request and SassTransformer
cecton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Added | ||
|
|
||
| - `DevServer::xtask(name)` and `DevServer::cargo(subcommand)` convenience | ||
| builders for setting the main watch command. These replace the old implicit | ||
| behavior where `arg()` would silently create an xtask command if none was set. | ||
| - `DevServer::arg()`, `DevServer::args()`, `DevServer::env()`, | ||
| `DevServer::envs()` restored as builder methods on `DevServer` for passing | ||
| extra arguments/environment to the `xtask()` and `cargo()` shorthands (which | ||
| build the command internally). These now panic with a clear message if called | ||
| before a command is set — a programmer error, not a runtime condition. | ||
| - `DevServer::dist_dir(path)` builder to explicitly set the directory served by | ||
| the dev server (previously had to be passed to `start()`). | ||
| - `Hook` trait for `DevServer` pre/post commands. Lets you construct a | ||
| `process::Command` with access to the final server configuration (e.g. | ||
| resolved `port`, `dist_dir`). A blanket impl is provided for | ||
| `process::Command` itself. | ||
| - `Transformer` trait for `Dist` asset processing. Transformers are tried in | ||
| order per file; the first to return `Ok(true)` claims the file, unclaimed | ||
| files are plain-copied. Errors are propagated immediately via `?`. | ||
| - `Dist::transformer(impl Transformer)` builder to register asset transformers. | ||
| - `SassTransformer` struct (behind the `sass` feature) implementing `Transformer` | ||
| to compile SASS/SCSS files to CSS. | ||
| - `Dist::optimize_wasm(WasmOpt)` builder (behind the `wasm-opt` feature) to | ||
| integrate wasm-opt directly into the `build()` pipeline. Automatically skipped | ||
| for debug builds. | ||
| - `Dist::default_debug_dir()` and `Dist::default_release_dir()` associated | ||
| functions returning `camino::Utf8PathBuf`. | ||
| - "Why xtask-wasm?" section added to the README and crate-level documentation. | ||
|
|
||
| ### Changed | ||
|
|
||
| - **BREAKING** `DevServer::start()` no longer takes a `dist_dir` path argument. | ||
| The directory is inferred from `Dist::default_debug_dir()` or set via the new | ||
| `DevServer::dist_dir()` builder. | ||
| - **BREAKING** `DevServer::command()` now accepts a `process::Command` instead | ||
| of a program name string, consistent with `pre()` and `post()`. | ||
| - **BREAKING** `DevServer::not_found()` renamed to `DevServer::not_found_path()`. | ||
| - **BREAKING** `Dist::run()` renamed to `Dist::build()`. | ||
| - **BREAKING** `Dist::dist_dir_path()` renamed to `Dist::dist_dir()`. | ||
| - **BREAKING** `Dist::static_dir_path()` renamed to `Dist::assets_dir()`. The | ||
| assets directory is now auto-discovered at `<package_root>/assets` when not | ||
| explicitly set. The copy step is silently skipped (with a `log::debug!`) if | ||
| the directory does not exist, allowing users with custom asset pipelines to | ||
| call `build()` without a pre-existing assets directory on disk. | ||
| - **BREAKING** `run_in_workspace` field and `use_workspace_root()` / | ||
| `use_current_dir()` methods removed from `Dist`. The build command always runs | ||
| from the workspace root, which was the correct value in virtually all | ||
| use-cases. The `false` branch was unreliable anyway since Cargo crate | ||
| resolution requires being inside the workspace. | ||
| - **BREAKING** `SassTransformer` is now opt-in. Previously `Dist::default()` | ||
| would auto-seed a `SassTransformer` when the `sass` feature was enabled, | ||
| meaning any user adding their own `SassTransformer` would silently end up with | ||
| two in the pipeline. Use `.transformer(SassTransformer::default())` to opt in. | ||
| - **BREAKING** `Request::dist_dir_path` field renamed to `Request::dist_dir`. | ||
| - `Dist::default_debug_dir()` and `Dist::default_release_dir()` now return an | ||
| owned `camino::Utf8PathBuf` instead of `&'static camino::Utf8Path`, removing | ||
| the `lazy_static` machinery and the `.as_std_path().to_path_buf()` boilerplate | ||
| at call sites. | ||
| - `walkdir` promoted from a `sass`-feature-gated dependency to a regular | ||
| dependency (used unconditionally by `copy_assets`). | ||
| - `cfg_not_wasm32!` / `cfg_wasm32!` / `cfg_sass!` / `cfg_wasm_opt!` / | ||
| `cfg_run_example!` macros removed. These wrapped `mod` declarations inside | ||
| macro bodies, making those modules invisible to `cargo fmt` and silently | ||
| skipping format checks on the bulk of the codebase. Replaced with plain | ||
| `#[cfg(...)]` attributes. | ||
| - MSRV bumped to 1.88. | ||
| - `run_example` macro: `static_dir` argument renamed to `assets_dir`. | ||
| - `run_example` macro: default `index.html` is no longer generated when | ||
| `app_name` is set. The default template hardcodes `app.js`/`app_bg.wasm`; | ||
| with a custom app name those filenames are wrong. Users setting `app_name` | ||
| should provide their own `index.html` via the `index` argument or in their | ||
| assets directory. | ||
|
|
||
| ### Removed | ||
|
|
||
| - **BREAKING** Free functions `default_dist_dir(release: bool)`, | ||
| `default_dist_dir_debug()`, and `default_dist_dir_release()` removed in favor | ||
| of `Dist::default_debug_dir()` and `Dist::default_release_dir()`. | ||
| - **BREAKING** `Dist::sass_options()` removed. Configure SASS compilation | ||
| options via `SassTransformer { options: ... }` passed to `Dist::transformer()`. | ||
|
|
||
| ### Fixed | ||
|
|
||
| - `SassTransformer`: SASS compilation errors are now propagated as `Err` instead | ||
| of panicking. | ||
| - `copy_assets`: transformer errors are now propagated immediately. The previous | ||
| iterator chain used `find()` with `map_or(false, ...)` which treated `Err` as | ||
| `false` and silently fell through to the plain-copy fallback. | ||
| - Auto-discovery was looking for a `public/` directory while the rest of the | ||
| codebase used `assets`, silently breaking auto-discovery for anyone following | ||
| the documented naming convention. | ||
|
|
||
| [Unreleased]: https://github.com/rustminded/xtask-wasm/compare/v0.5.3...HEAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.