Closed kyr0 closed 2 years ago
Additional info: Error disappears immediately when removing the line containing the $s in the multiline template string
"astro": "^0.21.0-next.1"
Stacktrace:
Error: Unable to parse {"file":"/Users/aron/Code/8080asm/src/pages/index.astro","line":20,"column":18}
18 | msg$: DB 'Hello, world!
19 | <body>
20 | <main class="astro-7PTCINDU">
| ^
21 | <header class="astro-7PTCINDU">
22 | <div class="astro-7PTCINDU">
at traverseHtml (/Users/aron/Code/8080asm/node_modules/astro/vendor/vite/dist/node/chunks/dep-35df7f96.js:21231:15)
at async devHtmlHook (/Users/aron/Code/8080asm/node_modules/astro/vendor/vite/dist/node/chunks/dep-35df7f96.js:56965:5)
at async applyHtmlTransforms (/Users/aron/Code/8080asm/node_modules/astro/vendor/vite/dist/node/chunks/dep-35df7f96.js:21541:21)
at async ssr (file:///Users/aron/Code/8080asm/node_modules/astro/dist/core/ssr/index.js:145:14)
at async AstroDevServer.handleHotUpdate (file:///Users/aron/Code/8080asm/node_modules/astro/dist/core/dev/index.js:84:20)
at async handleHMRUpdate (/Users/aron/Code/8080asm/node_modules/astro/vendor/vite/dist/node/chunks/dep-35df7f96.js:57255:37)
at async FSWatcher.<anonymous> (/Users/aron/Code/8080asm/node_modules/astro/vendor/vite/dist/node/chunks/dep-35df7f96.js:66802:17)
Can confirm that this is broken. https://stackblitz.com/edit/github-ru6xx6?file=src%2Fpages%2Findex.astro
Will make sure this gets fixed before v0.21 goes out.
Thank you :) This one also doesn't work, but somehow on Stackblitz it works... however same version (next.2 now) doesn't work locally with:
const asmCode = `
; Simple example
; Writes Hello World to the output
JMP start
hello: DB "Hello World!" ; Variable
DB 0 ; String terminator
start:
MOV C, hello ; Point to var
MOV D, 232 ; Point to output
CALL print
HLT ; Stop execution
print: ; print(C:*from, D:*to)
PUSH A
PUSH B
MOV B, 0
.loop:
MOV A, [C] ; Get char from var
MOV [D], A ; Write to output
INC C
INC D
CMP B, [C] ; Check if end
JNZ .loop ; jump if not
POP B
POP A
RET
`;
Unable to parse {"file":"/Users/aron/Code/8080asm/src/pages/index.astro","line":15,"column":12}
13 |
14 | JMP start
15 | hello: DB "Hello World!" ; Variable
| ^
16 | DB 0 ; String terminator
17 |
Doens't accept " quoutes in multiline template string
Sorry this didn't get out before 0.21! I'm taking a look at this now.
Transferring to the compiler repo to keep everything organized.
Update: I was thinking this was a compiler issue, but I confirmed that these are all handled correctly in the compiler!
I did look at the stacktraces and determined that these may have been thrown by Vite's internal HTML parser...
@kyr0 is it possible to try this again on astro@0.21.7
and share a full reproduction link if the issue is still happening? I suspect that it has been fixed.
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
I've a simple astro component with JS + HTML.
It contains the following code in JS section:
Passing this code down to another astro component like this:
<Editor code={asmCode} />
Leads to an error: Unable to parse {"file":"/Users/aron/Code/8080asm/src/pages/index.astro","line":20,"column":18}
I'm pretty sure that this is due to the line containing $ without following {} -- maybe the astro code is assuming every $ in a template string to be followed by a {} to form a variable, however, it is perfectly valid to just put $ at arbitrary places.
Steps to Reproduce
npm init astro
astro dev
Link to Minimal Reproducible Example (Optional)
No response