diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index fc6cd9fef..a64dada0f 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2216,6 +2216,17 @@ impl<'a> ModuleDeclaration<'a> { | Self::TSNamespaceExportDeclaration(_) => None, } } + + pub fn with_clause(&self) -> Option<&WithClause<'a>> { + match self { + Self::ImportDeclaration(decl) => decl.with_clause.as_ref(), + Self::ExportAllDeclaration(decl) => decl.with_clause.as_ref(), + Self::ExportNamedDeclaration(decl) => decl.with_clause.as_ref(), + Self::ExportDefaultDeclaration(_) + | Self::TSExportAssignment(_) + | Self::TSNamespaceExportDeclaration(_) => None, + } + } } #[derive(Debug, Hash)] diff --git a/crates/oxc_prettier/src/format/module.rs b/crates/oxc_prettier/src/format/module.rs index 6d035eac7..9e34fabf2 100644 --- a/crates/oxc_prettier/src/format/module.rs +++ b/crates/oxc_prettier/src/format/module.rs @@ -35,6 +35,11 @@ pub(super) fn print_export_declaration<'a>( parts.push(source.format(p)); } + if let Some(with_clause) = decl.with_clause() { + parts.push(space!()); + parts.push(with_clause.format(p)); + } + if let Some(doc) = print_semicolon_after_export_declaration(p, decl) { parts.push(doc); } diff --git a/tasks/prettier_conformance/prettier.js.snap.md b/tasks/prettier_conformance/prettier.js.snap.md index 589c842b8..4ca03f635 100644 --- a/tasks/prettier_conformance/prettier.js.snap.md +++ b/tasks/prettier_conformance/prettier.js.snap.md @@ -1,4 +1,4 @@ -js compatibility: 258/586 (44.03%) +js compatibility: 264/586 (45.05%) # Failed @@ -261,20 +261,10 @@ js compatibility: 258/586 (44.03%) ### import-assertions * import-assertions/empty.js -* import-assertions/re-export.js - -### import-assertions/bracket-spacing -* import-assertions/bracket-spacing/empty.js -* import-assertions/bracket-spacing/re-export.js ### import-attributes * import-attributes/empty.js * import-attributes/keyword-detect.js -* import-attributes/re-export.js - -### import-attributes/bracket-spacing -* import-attributes/bracket-spacing/empty.js -* import-attributes/bracket-spacing/re-export.js ### label * label/comment.js