Emitter in SWC does not add expected space after '=>' in Arrow Functions

Hello friends, I am new to rust and SWC, I hope I am not wasting your time 🥹🙏🏻 I edited with extra space.
// This is first test we need to have
console.log("We are here");
// This is another comment
const add = () => {
// This is inner content
return "Test" + "Test";
};


const min = () => {return "Test" + "Test"};
// This is first test we need to have
console.log("We are here");
// This is another comment
const add = () => {
// This is inner content
return "Test" + "Test";
};


const min = () => {return "Test" + "Test"};
Now I want to edit the add to adds, I is more than 2000 character and discord dose not let me send the code, so I put it in gist: https://gist.github.com/shahryarjb/6f314fa7fab85fb09751bb8146c919f3 My problem is it returns
// This is first test we need to have
console.log("We are here");
// This is another comment
const adds = ()=>{
// This is inner content
return "Shahryar" + "Tavakkoli";
};
const min = ()=>{
return "Shahryar" + "Tavakkoli";
};
// This is first test we need to have
console.log("We are here");
// This is another comment
const adds = ()=>{
// This is inner content
return "Shahryar" + "Tavakkoli";
};
const min = ()=>{
return "Shahryar" + "Tavakkoli";
};
but I need to have an space after => and before{} like this
const adds = () => {
// This is inner content
return "Test" + "Test";
};
const adds = () => {
// This is inner content
return "Test" + "Test";
};
how can do it? Thank you in advance
Gist
rust-swc.rs
GitHub Gist: instantly share code, notes, and snippets.
4 Replies
kdy1
kdy13w ago
You should fork swc_ecma_codegen
Shahryar
ShahryarOP3w ago
Sorry as I understood there is no option and If i want to edit this I should change the lib source? Sorry I am not native english speaker
kdy1
kdy13w ago
Yeap
Shahryar
ShahryarOP3w ago
@kdy1 Sorry for interrupting, the space between lines like the top post needs to change source? I mean
let code = r#"
import "phoenix_html";
import { Socket, SocketV1 } from "phoenix";
import { TS } from "tsobject";

// This is first test we need to have
console.log("We are here");

const min = () => {return "Shahryar" + "Tavakkoli"};
"#;
let code = r#"
import "phoenix_html";
import { Socket, SocketV1 } from "phoenix";
import { TS } from "tsobject";

// This is first test we need to have
console.log("We are here");

const min = () => {return "Shahryar" + "Tavakkoli"};
"#;
For now my code delete all the spaces
import "phoenix_html";
import { Socket, SocketV1 } from "phoenix";
import { TS } from "tsobject";
// This is first test we need to have
console.log("We are here");
const min = ()=>{
return "Shahryar" + "Tavakkoli";
};
import "phoenix_html";
import { Socket, SocketV1 } from "phoenix";
import { TS } from "tsobject";
// This is first test we need to have
console.log("We are here");
const min = ()=>{
return "Shahryar" + "Tavakkoli";
};
Thank you in advance --- This is my emmiter
let mut emitter = Emitter {
cfg: Config::default().with_minify(false),
cm: cm.clone(),
comments: Some(&comments),
wr: JsWriter::new(cm.clone(), "\n", &mut buf, None),
};
let mut emitter = Emitter {
cfg: Config::default().with_minify(false),
cm: cm.clone(),
comments: Some(&comments),
wr: JsWriter::new(cm.clone(), "\n", &mut buf, None),
};

Did you find this page helpful?