File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
packages/compiler/src/babel-utils Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @marko/compiler " : patch
3
+ ---
4
+
5
+ Prevent loss of comments in a scriptlet without statements
Original file line number Diff line number Diff line change @@ -134,9 +134,15 @@ function tryParse(
134
134
parserOpts . startColumn = startColumn ;
135
135
136
136
try {
137
- return isExpression
138
- ? babelParser . parseExpression ( code , parserOpts )
139
- : babelParser . parse ( code , parserOpts ) . program . body ;
137
+ if ( isExpression ) {
138
+ return babelParser . parseExpression ( code , parserOpts ) ;
139
+ } else {
140
+ const { program } = babelParser . parse ( code , parserOpts ) ;
141
+ if ( program . innerComments ) {
142
+ return babelParser . parse ( `;${ code } ` , parserOpts ) . program . body ;
143
+ }
144
+ return program . body ;
145
+ }
140
146
} catch ( err ) {
141
147
const parseError = createParseError (
142
148
file ,
You can’t perform that action at this time.
0 commit comments