@@ -245,7 +245,7 @@ fn migrate_imports<'a>(
245245 // to:
246246 // ```
247247 // import * as dialog from "@tauri-apps/plugin-dialog"
248- // import * as cli as superCli from "@tauri-apps/plugin-cli"
248+ // import * as superCli from "@tauri-apps/plugin-cli"
249249 // ```
250250 import if PLUGINIFIED_MODULES . contains ( & import) && module == "@tauri-apps/api" => {
251251 let js_plugin: & str = MODULES_MAP [ & format ! ( "@tauri-apps/api/{import}" ) ] ;
@@ -255,9 +255,7 @@ fn migrate_imports<'a>(
255255
256256 if specifier. local . name . as_str ( ) != import {
257257 let local = & specifier. local . name ;
258- imports_to_add. push ( format ! (
259- "\n import * as {import} as {local} from \" {js_plugin}\" "
260- ) ) ;
258+ imports_to_add. push ( format ! ( "\n import * as {local} from \" {js_plugin}\" " ) ) ;
261259 } else {
262260 imports_to_add. push ( format ! ( "\n import * as {import} from \" {js_plugin}\" " ) ) ;
263261 } ;
@@ -359,6 +357,39 @@ mod tests {
359357 use super :: * ;
360358 use pretty_assertions:: assert_eq;
361359
360+ fn assert_migrated_output_parses ( path : & Path , source : & str ) {
361+ let has_partial_js = path
362+ . extension ( )
363+ . is_some_and ( |ext| ext == "vue" || ext == "svelte" ) ;
364+
365+ let sources = if !has_partial_js {
366+ vec ! [ ( SourceType :: from_path( path) . unwrap( ) , source. to_string( ) ) ]
367+ } else {
368+ partial_loader:: PartialLoader :: parse (
369+ path
370+ . extension ( )
371+ . unwrap_or_default ( )
372+ . to_str ( )
373+ . unwrap_or_default ( ) ,
374+ source,
375+ )
376+ . unwrap ( )
377+ . into_iter ( )
378+ . map ( |s| ( s. source_type , s. source_text . to_string ( ) ) )
379+ . collect ( )
380+ } ;
381+
382+ for ( source_type, script_source) in sources {
383+ let allocator = Allocator :: default ( ) ;
384+ let ret = Parser :: new ( & allocator, & script_source, source_type) . parse ( ) ;
385+ assert ! (
386+ ret. errors. is_empty( ) ,
387+ "migrated output did not parse: {:?}" ,
388+ ret. errors
389+ ) ;
390+ }
391+ }
392+
362393 #[ test]
363394 fn migrates_vue ( ) {
364395 let input = r#"
@@ -404,7 +435,7 @@ mod tests {
404435 import * as fs from "@tauri-apps/plugin-fs";
405436 import "./App.css";
406437import * as dialog from "@tauri-apps/plugin-dialog"
407- import * as cli as superCli from "@tauri-apps/plugin-cli"
438+ import * as superCli from "@tauri-apps/plugin-cli"
408439const appWindow = getCurrentWebviewWindow()
409440</script>
410441
@@ -428,6 +459,7 @@ const appWindow = getCurrentWebviewWindow()
428459 . unwrap ( ) ;
429460
430461 assert_eq ! ( migrated, expected) ;
462+ assert_migrated_output_parses ( Path :: new ( "file.vue" ) , & migrated) ;
431463
432464 assert_eq ! (
433465 new_plugins,
@@ -479,7 +511,7 @@ const appWindow = getCurrentWebviewWindow()
479511 import * as fs from "@tauri-apps/plugin-fs";
480512 import "./App.css";
481513import * as dialog from "@tauri-apps/plugin-dialog"
482- import * as cli as superCli from "@tauri-apps/plugin-cli"
514+ import * as superCli from "@tauri-apps/plugin-cli"
483515const appWindow = getCurrentWebviewWindow()
484516</script>
485517"# ;
@@ -496,6 +528,7 @@ const appWindow = getCurrentWebviewWindow()
496528 . unwrap ( ) ;
497529
498530 assert_eq ! ( migrated, expected) ;
531+ assert_migrated_output_parses ( Path :: new ( "file.svelte" ) , & migrated) ;
499532
500533 assert_eq ! (
501534 new_plugins,
@@ -598,7 +631,7 @@ import { Store } from "@tauri-apps/plugin-store";
598631import Database from "@tauri-apps/plugin-sql";
599632import "./App.css";
600633import * as dialog from "@tauri-apps/plugin-dialog"
601- import * as cli as superCli from "@tauri-apps/plugin-cli"
634+ import * as superCli from "@tauri-apps/plugin-cli"
602635const appWindow = getCurrentWebviewWindow()
603636
604637function App() {
@@ -670,6 +703,7 @@ export default App;
670703 . unwrap ( ) ;
671704
672705 assert_eq ! ( migrated, expected) ;
706+ assert_migrated_output_parses ( Path :: new ( "file.js" ) , & migrated) ;
673707
674708 assert_eq ! (
675709 new_plugins,
0 commit comments