Skip to content

Commit

Permalink
fix(es/plugin): Migrate swc plugin new to use .cargo/config.toml (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
SpanishPear authored Nov 18, 2024
1 parent d437fd8 commit 4ffb21e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/sixty-walls-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: patch
swc_cli_impl: patch
---

Migrate to config.toml to fix warning
6 changes: 3 additions & 3 deletions crates/swc_cli_impl/src/commands/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"#,
Expand All @@ -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.
Expand Down

0 comments on commit 4ffb21e

Please sign in to comment.