-
Notifications
You must be signed in to change notification settings - Fork 246
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
Re-thinking configuration #780
Comments
Why not eliminate the Other, mature bundlers, such as See https://www.cargo-lambda.info/commands/watch.html#environment-variables For example, the Cargo.toml would look like this: [package]
name = "basic-app"
[package.metadata.trunk.env]
RUST_LOG = "debug"
CARGO_PROFILE = "release"
[package.metadata.trunk.serve]
TRUNK_SERVE_ADDRESS = "127.0.0.1"
TRUNK_SERVE_PORT = 8080 I also think this fits better into the bevy ecosystem. In addition, environment variables are notoriously hard to work with in WASM, since they don't exist, but are still needed typically for things like deployments/environments, e.g. dev/stg/prod. Today, if you want to have real deployment config for WASM apps, you have essentially three options: Static: pub const ENVIRONMENT = "dev"; Semi-static:
pub const ENVIRONMENT = env!("ENV"); Fully dynamic, but requires features and special handling: #[cfg(feature = "prod")]
pub const ENVIRONMENT = "prod";
#[cfg(feature = "stage")]
pub const ENVIRONMENT = "stg";
#[cfg(feature = "dev")]
pub const ENVIRONMENT = "dev"; |
I personally see I right the opposite way. I think having "trunk" config in a "trunk config file" makes more sense, rather than adding noise to the "cargo config". And there are other examples that go exactly that way ( So I definitely would not want to force people into either direction. If possible, enable the use of When talking about env-vars, that was more about the configuration, less about the actual code. Right now, instead of using CLI arguments, one can use env-vars to provide that configuration to For having those deployment style options, I think it makes sense to go into the direction of "build profiles". Something similar to cargo profiles: [profile.release]
minify = true
features = ["foo"] [profile.release-stage]
inherits = "release"
minify = true
features = ["foo", "stage"] That could be aligned with cargo profiles too. So that enabling profile |
re: Cargo.toml config - Personally I see more people using the Cargo.toml than a bespoke file. I think it should've been the default from the beginning, personally. Examples:
I think we're the odd man out, or at the least should support Cargo.toml configuration.
Are cargo profile features a thing? I'm not seeing any documentation for profile features. A stack overflow issue 3 years ago suggests this isn't allowed, either. However if it does exist, I would be happy with that! #605 would solve my problems with multi-stage environments. |
Not from cargo, but that would be the part the trunk would add. Still, selecting a trunk profile might also trigger the selection of a cargo profile. Maybe as opt-in, to not require a cargo profile for using trunk profiles. I think when it comes to Cargo.toml vs Trunk.toml, you can find may examples for each side. But let's take a look at |
Let's plan to support both. As far as the cargo features go, I want to avoid confusion. Anything that would exist in the // Cargo.toml
[profile.release]
minify = true
[package.metadata.trunk.profile.release]
features = ["prod"]
[profile.release-stage]
inherits = "release"
minify = true
[package.metadata.trunk.profile.release-stage]
features = ["stage"] On the Trunk.toml, though, we don't have to do that: // Cargo.toml
[profile.release]
minify = true
[profile.release-stage]
inherits = "release"
minify = true // Trunk.toml
[profile.release]
features = ["prod"]
[profile.release-stage]
features = ["stage"] |
Yup, that sounds great. Personally I would also be keen on seeing: # Trunk.yaml
$schema: "trunkrs.dev/config.schema.json"
profile:
release:
features: ["prod"]
release-stage:
features: ["prod"] Assuming that's added by only a few lines of extra code. But the focus, for sure, should be on |
Thinking about "when", I would prefer to finish up |
I'd prefer a |
Sure, this feels like a great change. Probably the highest on my priority list, among workspace support. |
Well, that would not allow editor support. And that's the whole idea behind that schema. Being able to auto-complete configurations. |
Sounds good- We could do |
Btw, I am slowly working towards this (as time permits). There's nothing to share yet, but I'll share a PR as soon as there is something that compiles. |
There's an initial draft PR. It's not finished and lacks |
Loving the progress @ctron ! This has, by far, been the most requested thing I've wanted for years. :) |
Can this be closed since #795 was merged? |
I am not 100% sure where are there yet. So the answer is: maybe :) But let's keep it open until it's released and everyone (mostly everyone … some people) are happy. |
Right now there's a layer of configurations (order of priority, former will override latter):
Trunk.toml
config (serde)The result is then passed on internally to structs for processing.
There are some areas of improvement:
false
)There are also some pending feature requests which seem to have an impact on the configuration:
Cargo.toml
(personally I am not a fan of this, bet maybe we can have it both ways)Bonus points:
The text was updated successfully, but these errors were encountered: