From 4ffb21ebe6e40f85f8b7f78cd29b10965fe035b1 Mon Sep 17 00:00:00 2001 From: Shrey Sudhir Date: Mon, 18 Nov 2024 12:10:15 +1100 Subject: [PATCH] fix(es/plugin): Migrate `swc plugin new` to use `.cargo/config.toml` (#9740) **Description:** As per https://doc.rust-lang.org/cargo/reference/config.html we should be generating a `.cargo/config.toml` instead of `.cargo/config` when creating a new plugin **BREAKING CHANGE:** Technically this means users **must** have a toolchain > 1.38 (released september, 2019 - so five years ago). Given that: - the [public documentation for swc plugins](https://swc.rs/docs/plugin/ecmascript/getting-started#install-rust) link directly to the latest version of the rust toolchain (currently 1.81) - 1.38 was > **five years ago** - This only impacts **new** usages of `swc plugin new ..` - README.md specifies that the `swc-project/swc` MSRV is 1.73 anyways - whilst that doesn't **specifically** refer to **generated** code, it shows the intent of the project :) I don't believe it will have material impact. I will raise a separate PR to generate the correct MSRV for both `swc-project/swc` **and** the generated plugin itself. --- .changeset/sixty-walls-hang.md | 6 ++++++ crates/swc_cli_impl/src/commands/plugin.rs | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/sixty-walls-hang.md diff --git a/.changeset/sixty-walls-hang.md b/.changeset/sixty-walls-hang.md new file mode 100644 index 000000000000..bb916c0a15a3 --- /dev/null +++ b/.changeset/sixty-walls-hang.md @@ -0,0 +1,6 @@ +--- +swc_core: patch +swc_cli_impl: patch +--- + +Migrate to config.toml to fix warning diff --git a/crates/swc_cli_impl/src/commands/plugin.rs b/crates/swc_cli_impl/src/commands/plugin.rs index a481b46b1d24..2b0ec8ca4e49 100644 --- a/crates/swc_cli_impl/src/commands/plugin.rs +++ b/crates/swc_cli_impl/src/commands/plugin.rs @@ -165,7 +165,7 @@ lto = true serde = "1" swc_core = {{ version = "{}", features = ["ecma_plugin_transform"] }} -# .cargo/config defines few alias to build plugin. +# .cargo/config.toml defines few alias to build plugin. # cargo build-wasi generates wasm-wasi32 binary # cargo build-wasm32 generates wasm32-unknown-unknown binary. "#, @@ -185,11 +185,11 @@ swc_core = {{ version = "{}", features = ["ecma_plugin_transform"] }} PluginTargetType::Wasm32Wasi => "build-wasi", }; - // Create cargo config for build target + // Create `.cargo/config.toml` file for build target let cargo_config_path = path.join(".cargo"); create_dir_all(&cargo_config_path).context("`create_dir_all` failed")?; fs::write( - cargo_config_path.join("config"), + cargo_config_path.join("config.toml"), r#"# These command aliases are not final, may change [alias] # Alias to build actual plugin binary for the specified target.