Closed anthonyalayo closed 2 years ago
Hi @anthonyalayo
It seems like you have a .babelrc
file in your project, is that correct? Because I could reproduce your issue only by having a .babelrc
file in the project.
If you have it, indeed you have to have the correct configuration (as you posted), on the other hand if you want to use SWC, you shouldn't have a babel configuration file.
Hey @ggurkal
Sorry if it wasn't clear. I did not have a .babelrc in my project. Without it, it gave me the screenshot I put on the issue. I was forced to add the .babelrc just so I could have something working as a workaround in the meantime. I want to remove it. 😄
I just created a project with create-next-app
, installed this package and used the decorators without any problem. It'd be helpful if you could create a repo that reproduces your error.
@ggurkal, how's this?
Upon building the example, I saw it binary pass/fail after doing this: https://github.com/storyofams/next-api-decorators/issues/402#issuecomment-1115888121
Hey @anthonyalayo
You're using the next-superjson
package which injects a babel plugin on files under the pages
directory. As it's stated in their readme: https://www.npmjs.com/package/next-superjson
This plugin will inject the superjson babel plugin only on files under the pages directory so you can keep using swc for all the other files.
When I replaced module.exports = withSuperjson()(nextConfig)
with module.exports = nextConfig
, it started working.
Aha, interesting. So it looks like superjson isn't compatible.. that's unfortunate. Thank you!
Describe the bug When attempting to build a NextJS 12 project with SWC, it errors out with:
Syntax error: Support for the experimental syntax 'decorators-legacy' isn't currently enabled
To Reproduce Steps to reproduce the behavior:
Expected behavior It builds and runs.
Screenshot
Notes When attempting to build the project with the following
.babelrc
:it works as expected. A solution with SWC would be ideal.
The docs state that this project works with SWC by setting some flags in the
tsconfig.json
: https://next-api-decorators.vercel.app/docs/#using-with-swcThis does not work, as demonstrated in the screenshot.