mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-11 14:46:04 +00:00
Merge pull request #827 from joshtriplett/clean-up-generated-code
Clean up indentation and blanks in the generated --no-modules JavaScript
This commit is contained in:
commit
b66d1064d0
@ -417,7 +417,7 @@ impl<'a> Context<'a> {
|
|||||||
|
|
||||||
let mut js = if self.config.no_modules {
|
let mut js = if self.config.no_modules {
|
||||||
format!(
|
format!(
|
||||||
"
|
"\
|
||||||
(function() {{
|
(function() {{
|
||||||
var wasm;
|
var wasm;
|
||||||
const __exports = {{}};
|
const __exports = {{}};
|
||||||
@ -438,8 +438,7 @@ impl<'a> Context<'a> {
|
|||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
self.{global_name} = Object.assign(init, __exports);
|
self.{global_name} = Object.assign(init, __exports);
|
||||||
}})();
|
}})();",
|
||||||
",
|
|
||||||
globals = self.globals,
|
globals = self.globals,
|
||||||
module = module_name,
|
module = module_name,
|
||||||
global_name = self.config.no_modules_global
|
global_name = self.config.no_modules_global
|
||||||
|
@ -388,10 +388,12 @@ fn reset_indentation(s: &str) -> String {
|
|||||||
indent = indent.saturating_sub(1);
|
indent = indent.saturating_sub(1);
|
||||||
}
|
}
|
||||||
let extra = if line.starts_with(':') || line.starts_with('?') { 1 } else { 0 };
|
let extra = if line.starts_with(':') || line.starts_with('?') { 1 } else { 0 };
|
||||||
|
if !line.is_empty() {
|
||||||
for _ in 0..indent + extra {
|
for _ in 0..indent + extra {
|
||||||
dst.push_str(" ");
|
dst.push_str(" ");
|
||||||
}
|
}
|
||||||
dst.push_str(line);
|
dst.push_str(line);
|
||||||
|
}
|
||||||
dst.push_str("\n");
|
dst.push_str("\n");
|
||||||
if line.ends_with('{') {
|
if line.ends_with('{') {
|
||||||
indent += 1;
|
indent += 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user