Skip to content

Commit

Permalink
JS AST: fix output with indenting for newlines in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Nov 16, 2023
1 parent f48e531 commit 92e433b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions js/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,9 @@ func (n ImportStmt) String() string {

// JS writes JavaScript to writer.
func (n ImportStmt) JS(w io.Writer) {
if wi, ok := w.(Indenter); ok {
w = wi.w
}
w.Write([]byte("import"))
if n.Default != nil {
w.Write([]byte(" "))
Expand Down Expand Up @@ -1047,6 +1050,9 @@ func (n ExportStmt) String() string {

// JS writes JavaScript to writer.
func (n ExportStmt) JS(w io.Writer) {
if wi, ok := w.(Indenter); ok {
w = wi.w
}
w.Write([]byte("export"))
if n.Decl != nil {
if n.Default {
Expand Down Expand Up @@ -1092,6 +1098,9 @@ func (n DirectivePrologueStmt) String() string {

// JS writes JavaScript to writer.
func (n DirectivePrologueStmt) JS(w io.Writer) {
if wi, ok := w.(Indenter); ok {
w = wi.w
}
w.Write(n.Value)
w.Write([]byte(";"))
}
Expand Down Expand Up @@ -1160,6 +1169,9 @@ func (n PropertyName) JS(w io.Writer) {
w.Write([]byte("]"))
return
}
if wi, ok := w.(Indenter); ok {
w = wi.w
}
w.Write(n.Literal.Data)
}

Expand Down

0 comments on commit 92e433b

Please sign in to comment.