mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(codegen): print space before with clause in import (#2278)
This commit is contained in:
parent
3569e42475
commit
0c225a49aa
2 changed files with 13 additions and 0 deletions
|
|
@ -654,6 +654,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ImportDeclaration<'a> {
|
|||
p.print(b'\'');
|
||||
p.print_str(self.source.value.as_bytes());
|
||||
p.print(b'\'');
|
||||
if self.with_clause.is_some() {
|
||||
p.print_hard_space();
|
||||
}
|
||||
self.with_clause.gen(p, ctx);
|
||||
p.print_semicolon_after_statement();
|
||||
return;
|
||||
|
|
@ -718,6 +721,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ImportDeclaration<'a> {
|
|||
p.print_str(b" from ");
|
||||
}
|
||||
self.source.gen(p, ctx);
|
||||
if self.with_clause.is_some() {
|
||||
p.print_hard_space();
|
||||
}
|
||||
self.with_clause.gen(p, ctx);
|
||||
p.print_semicolon_after_statement();
|
||||
}
|
||||
|
|
@ -734,6 +740,7 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for Option<WithClause<'a>> {
|
|||
impl<'a, const MINIFY: bool> Gen<MINIFY> for WithClause<'a> {
|
||||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
self.attributes_keyword.gen(p, ctx);
|
||||
p.print_soft_space();
|
||||
p.print_block(&self.with_entries, Separator::Comma, ctx);
|
||||
}
|
||||
}
|
||||
|
|
@ -815,6 +822,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ExportAllDeclaration<'a> {
|
|||
|
||||
p.print_str(b" from ");
|
||||
self.source.gen(p, ctx);
|
||||
if self.with_clause.is_some() {
|
||||
p.print_hard_space();
|
||||
}
|
||||
self.with_clause.gen(p, ctx);
|
||||
|
||||
p.print_semicolon_after_statement();
|
||||
|
|
|
|||
|
|
@ -104,4 +104,7 @@ fn template() {
|
|||
#[test]
|
||||
fn module_decl() {
|
||||
test("export * as foo from 'foo'", "export * as foo from 'foo';\n");
|
||||
test("import x from './foo.js' with {}", "import x from './foo.js' with {\n};\n");
|
||||
test("import {} from './foo.js' with {}", "import './foo.js' with {\n};\n");
|
||||
test("export * from './foo.js' with {}", "export * from './foo.js' with {\n};\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue