Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RollupError: Unexpected token @. during build while using it with @babel/plugin-proposal-decorators #24

Open
Verthon opened this issue May 20, 2024 · 0 comments

Comments

@Verthon
Copy link

Verthon commented May 20, 2024

Hello

I run into following issue: RollupError: Unexpected token @. Expected identifier, string literal, numeric literal or [ for the computed key when running build with the Vite

Dependencies:

  • typescript v5.4.5
  • vite v5.2.11
  • vite-plugin-babel v1.2.0
  • @babel/plugin-proposal-decorators v7.24.1
  • vite-tsconfig-paths v4.3.2

Decorator usage:

function log<
	Type,
	Context extends ClassMethodDecoratorContext | ClassFieldDecoratorContext,
	ReturnType
>(message: Type): (_: unknown, context: Context) => ReturnType {
	//@ts-ignore
	return (_, context) => {
		if (context.kind === "method") {
			return () => message;
		}

		return () => () => message;
	};
}

export class Example {
	@log("test")
	public doSomething = () => {
		console.log("test");
	};
}

Reproduction repository: https://github.com/Verthon/babel-plugin-decorators-repro

Current workaround:

we are using @vitejs/plugin-react even we don't use React 😅 but it works

react({
      babel: {
        plugins: [
          ['@babel/plugin-proposal-decorators', { version: '2023-05' }],
        ],
      },
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant