diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 7d9694ffca5d4..fd89cf7d7071b 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -1040,6 +1040,10 @@ impl Gen for ExportNamedDeclaration<'_> { p.print_str("from"); p.print_soft_space(); p.print_string_literal(source, false); + if let Some(with_clause) = &self.with_clause { + p.print_soft_space(); + with_clause.print(p, ctx); + } } p.print_semicolon_after_statement(); } diff --git a/crates/oxc_codegen/tests/integration/js.rs b/crates/oxc_codegen/tests/integration/js.rs index cdb6e4baa4f35..bd262e0059aaa 100644 --- a/crates/oxc_codegen/tests/integration/js.rs +++ b/crates/oxc_codegen/tests/integration/js.rs @@ -29,12 +29,21 @@ fn module_decl() { test("import x from './foo.js' with {}", "import x from \"./foo.js\" with {};\n"); test("import {} from './foo.js' with {}", "import {} from \"./foo.js\" with {};\n"); test("export * from './foo.js' with {}", "export * from \"./foo.js\" with {};\n"); + test( + "export { default } from './foo.js' with { type: 'json' }", + "export { default } from \"./foo.js\" with { type: \"json\" };\n", + ); + test("export {} from './foo.js' with {}", "export {} from \"./foo.js\" with {};\n"); test_minify("export { '☿' } from 'mod';", "export{\"☿\"}from\"mod\";"); test_minify("export { '☿' as '☿' } from 'mod';", "export{\"☿\"}from\"mod\";"); test_minify( "import x from './foo.custom' with { 'type': 'json' }", "import x from\"./foo.custom\"with{\"type\":\"json\"};", ); + test_minify( + "export { default } from './foo.js' with { type: 'json' }", + "export{default}from\"./foo.js\"with{type:\"json\"};", + ); } #[test]