withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
502 stars 59 forks source link

🐛 BUG: #869

Closed DanielTate closed 11 months ago

DanielTate commented 1 year ago

What version of @astrojs/compiler are you using?

2.1.0

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

Running npm run dev crashes

goroutine 32 [running]:
runtime/debug.Stack()
    runtime/debug/stack.go:24 +0x6
github.com/withastro/compiler/internal_wasm/utils.ErrorToJSError(0x47a900, {0x1812318, 0x648a08})
    github.com/withastro/compiler/internal_wasm/utils/utils.go:68 +0x2
main.Transform.func1.1.1.1()
    ./astro-wasm.go:290 +0x5
panic({0x2db80, 0x648a08})
    runtime/panic.go:884 +0x29
github.com/withastro/compiler/internal/sourcemap.(*ChunkBuilder).AddSourceMapping(0x755800, {0x770}, {0x75a000, 0xc4b, 0x1000})
    github.com/withastro/compiler/internal/sourcemap/sourcemap.go:678 +0x1e
github.com/withastro/compiler/internal/printer.(*printer).addSourceMapping(0x755738, {0x770})
    github.com/withastro/compiler/internal/printer/printer.go:447 +0x9
github.com/withastro/compiler/internal/printer.(*printer).printTextWithSourcemap(0x755738, {0x5650b0, 0x2b}, {0x758})
    github.com/withastro/compiler/internal/printer/printer.go:80 +0xf
github.com/withastro/compiler/internal/printer.render1(0x755738, 0x668a00, {0x0, 0x0, 0x6, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:283 +0x77
github.com/withastro/compiler/internal/printer.render1(0x755738, 0x6688c0, {0x0, 0x0, 0x5, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:704 +0x544
github.com/withastro/compiler/internal/printer.render1(0x755738, 0x668640, {0x0, 0x0, 0x4, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:652 +0x437
github.com/withastro/compiler/internal/printer.render1(0x755738, 0x6683c0, {0x0, 0x0, 0x3, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:652 +0x437
github.com/withastro/compiler/internal/printer.render1(0x755738, 0x668140, {0x0, 0x0, 0x2, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:652 +0x437
github.com/withastro/compiler/internal/printer.render1(0x755738, 0x5c8500, {0x0, 0x0, 0x1, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:652 +0x437
github.com/withastro/compiler/internal/printer.render1(0x755738, 0x5c8140, {0x1, 0x0, 0x0, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:125 +0xc6
github.com/withastro/compiler/internal/printer.printToJs(0x755738, 0x5c8140, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, {0x648750, 0x14}, {0x648780, ...}, ...})
    github.com/withastro/compiler/internal/printer/print-to-js.go:72 +0x3
github.com/withastro/compiler/internal/printer.PrintToJS({0x4f9500, 0x9fe}, 0x5c8140, 0x0, {{0x791ff8, 0x8}, {0x7e3d00, 0x32}, {0x648750, 0x14}, ...}, ...)
    github.com/withastro/compiler/internal/printer/print-to-js.go:53 +0xc
main.Transform.func1.1.1()
    ./astro-wasm.go:407 +0x38
created by main.Transform.func1.1
    ./astro-wasm.go:286 +0x14

I'm not putting my whole project in and example... Is there any way you can derive information from the stack trace?

I removed one of my components that uses fragments to inject HTML into another component.

I think what happened was I used the copy feature from figma and some whitespace char or not allowed char was included in the copy but wasn't showing in my editor. Might be worth looking into, I might dig into it if I get some time.

Link to Minimal Reproducible Example

https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics?file=README.md&on=stackblitz

MoustaphaDev commented 11 months ago

This was fixed in https://github.com/withastro/compiler/pull/902!