@@ -159,9 +159,14 @@ func preprocessStyle(i int, style *astro.Node, transformOptions transform.Transf
159
159
style .FirstChild .Data = str
160
160
}
161
161
162
+ func preprocessSource (source string ) string {
163
+ // remove trailing newlines
164
+ return strings .TrimRight (source , "\n " )
165
+ }
166
+
162
167
func Parse () interface {} {
163
168
return js .FuncOf (func (this js.Value , args []js.Value ) interface {} {
164
- source := jsString (args [0 ])
169
+ source := preprocessSource ( jsString (args [0 ]) )
165
170
parseOptions := makeParseOptions (js .Value (args [1 ]))
166
171
167
172
var doc * astro.Node
@@ -179,7 +184,7 @@ func Parse() interface{} {
179
184
180
185
func ConvertToTSX () interface {} {
181
186
return js .FuncOf (func (this js.Value , args []js.Value ) interface {} {
182
- source := jsString (args [0 ])
187
+ source := preprocessSource ( jsString (args [0 ]) )
183
188
transformOptions := makeTransformOptions (js .Value (args [1 ]), "XXXXXX" )
184
189
185
190
var doc * astro.Node
@@ -198,7 +203,7 @@ func ConvertToTSX() interface{} {
198
203
199
204
func Transform () interface {} {
200
205
return js .FuncOf (func (this js.Value , args []js.Value ) interface {} {
201
- source := jsString (args [0 ])
206
+ source := preprocessSource ( jsString (args [0 ]) )
202
207
hash := astro .HashFromSource (source )
203
208
transformOptions := makeTransformOptions (js .Value (args [1 ]), hash )
204
209
0 commit comments