adonisjs / lucid

AdonisJS SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
https://lucid.adonisjs.com/
MIT License
1.08k stars 193 forks source link

@computed decorator causing node ace to break #1057

Open atharahmed opened 2 weeks ago

atharahmed commented 2 weeks ago

Package version

21.3.0

Describe the bug

I was rewriting my app in AdonisJS v6, and after updating the packages to the latest version, I started receiving the following error:

[ info ] starting HTTP server...

   SyntaxError: Invalid or unexpected token

   at (syntax error) SyntaxError: Invalid or unexpected token

To debug this, I started with a fresh AdonisJS installation using the api starter kit. When I created a model with the @computed() property, I encountered the same error, and the server wouldn’t even start.

If I remove that property, the server starts, but I get the following error:

{
"message": "Cannot read properties of undefined (reading 'attributesToColumns')",
"name": "TypeError",
"status": 500,
"frames": []
}

I can query the database just fine using the database query builder, but the ORM fails. I’m using Node v20.18.0.

It can be the possible duplicate of issue 1056

Reproduction repo

https://github.com/atharahmed/hello-world

thetutlage commented 2 weeks ago

Hey!

Thanks for sharing the reproduction repo. The compiled output works fine, so it has to be something to do with SWC decorators support. Lemme debug further and see how that goes.

thetutlage commented 2 weeks ago

Its broken with @swc/core@1.7.35. If you downgrade to 1.7.26, it should work fine.