Skip to content
Latchkey

Rollup "Unexpected token" parse error in CI

Rollup parses JavaScript with Acorn and hit a token it does not understand. Rollup itself does not transpile TypeScript, JSX, or non-standard syntax, so without the right plugin it cannot read the file.

What this error means

The build fails with "[!] Error: Unexpected token (12:8)" and a file/location, often on a .ts, .jsx, or modern-syntax file.

rollup
[!] RollupError: Unexpected token (Note that you need plugins to import files
that are not JavaScript)
src/App.tsx (5:9)
5: const el = <App />;
            ^

Common causes

TypeScript or JSX without a transform plugin

Rollup's core parser does not handle TS or JSX, so the file fails unless a plugin (typescript, esbuild, babel) transforms it first.

Plugin order puts the parser before the transform

If a transform plugin runs after Rollup tries to parse, the original syntax reaches the parser and fails.

How to fix it

Add a transform plugin for the syntax

  1. Identify the file type Rollup could not parse.
  2. Add a plugin that transpiles it (for example @rollup/plugin-typescript or esbuild).
  3. Place it before plugins that expect plain JS.
rollup.config.js
// rollup.config.js
import typescript from '@rollup/plugin-typescript';
export default { plugins: [typescript()] };

Order plugins so transforms run first

Ensure the transform plugin precedes resolution/output plugins so Rollup never parses untransformed syntax.

How to prevent it

  • Add a transform plugin for every non-plain-JS file type.
  • Order plugins so transforms run before parsing-dependent steps.
  • Keep plugin versions compatible with your Rollup major.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →