wessberg / rollup-plugin-ts

A TypeScript Rollup plugin that bundles declarations, respects Browserslists, and enables seamless integration with transpilers such as babel and swc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decorators throw `Unexpected token '@'`.

selfagency opened this issue · comments

Hi! Am I missing something/doing something wrong that the plugin treats decorators as invalid syntax? Thanks!

Here's my config:

import tsConfigPaths from 'rollup-plugin-tsconfig-paths';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import ts from 'rollup-plugin-ts';

export default {
  input: 'lib/index.ts',
  output: {
    dir: 'dist',
    format: 'cjs',
  },
  plugins: [
    tsConfigPaths(),
    nodeResolve({extensions: ['.tsx', '.ts', '.jsx', '.js', '.json']}),
    ts({
      transpiler: 'swc',
      browserslist: false,
      swcConfig: {
        minify: true,
      },
    }),
  ],
};

And here's the output:

lib/index.ts → dist...
[!] (plugin Typescript) Error: 
  × Unexpected token `@`. Expected identifier, string literal, numeric literal or [ for the computed key
    ╭─[/Users/daniel/code/unstoppable-domains-website/backend/lib/entities/FastlyCachableModel.ts:79:3]
 79 │ @AfterInsert()
    · ─
    ╰────

Caused by:
    0: failed to process input file
    1: Syntax Error


lib/entities/FastlyCachableModel.ts
Error: 
  × Unexpected token `@`. Expected identifier, string literal, numeric literal or [ for the computed key
    ╭─[/Users/daniel/code/unstoppable-domains-website/backend/lib/entities/FastlyCachableModel.ts:79:3]
 79 │ @AfterInsert()
    · ─
    ╰────

Caused by:
    0: failed to process input file
    1: Syntax Error