Skip to content

Commit

Permalink
fix(cli): incorrect JS generated by frontend migration closes #10500 (#…
Browse files Browse the repository at this point in the history
…10542)

* fix(cli): incorrect JS generated by frontend migration closes #10500
  • Loading branch information
lucasfernog authored Aug 12, 2024
1 parent f3837d5 commit 3beba92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-v1-frontend-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Fixes v1 frontend code migration when using plugin default imports.
14 changes: 8 additions & 6 deletions tooling/cli/src/migrate/migrations/v1/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ fn migrate_imports<'a>(
// ```
// to:
// ```
// import dialog from "@tauri-apps/plugin-dialog"
// import cli as superCli from "@tauri-apps/plugin-cli"
// import * as dialog from "@tauri-apps/plugin-dialog"
// import * as cli as superCli from "@tauri-apps/plugin-cli"
// ```
import if PLUGINIFIED_MODULES.contains(&import) && module == "@tauri-apps/api" => {
let js_plugin: &str = MODULES_MAP[&format!("@tauri-apps/api/{import}")];
Expand All @@ -219,9 +219,11 @@ fn migrate_imports<'a>(

if specifier.local.name.as_str() != import {
let local = &specifier.local.name;
imports_to_add.push(format!("\nimport {import} as {local} from \"{js_plugin}\""));
imports_to_add.push(format!(
"\nimport * as {import} as {local} from \"{js_plugin}\""
));
} else {
imports_to_add.push(format!("\nimport {import} from \"{js_plugin}\""));
imports_to_add.push(format!("\nimport * as {import} from \"{js_plugin}\""));
};
None
}
Expand Down Expand Up @@ -393,8 +395,8 @@ import { register } from "@tauri-apps/plugin-global-shortcut";
import clipboard from "@tauri-apps/plugin-clipboard-manager";
import * as fs from "@tauri-apps/plugin-fs";
import "./App.css";
import dialog from "@tauri-apps/plugin-dialog"
import cli as superCli from "@tauri-apps/plugin-cli"
import * as dialog from "@tauri-apps/plugin-dialog"
import * as cli as superCli from "@tauri-apps/plugin-cli"
const appWindow = getCurrentWebviewWindow()
function App() {
Expand Down

0 comments on commit 3beba92

Please sign in to comment.