Rollup with typescript using babel

Babel doesn’t support the import type syntax, just use import. import type is an instruction to a Typescript compiler, which Babel is not (it just strips the types). Re the error message, at the minute it’s assuming you’re using Flow, which also uses that syntax.

1 Like

Thank you. that worked, and the explanation was really helpful.

1 Like

You don’t necessarily need Babel – check that you do before just installing it. The Rollup Typescript plugin (rollup-plugin-typescript2) will handle things just fine, leveraging the Typescript compiler. The advantage of Babel is that it’s generally a bit faster, but there’s quite a bit of extra plumbing to do to get that (whereas just Rollup’s Typescript plugin + the tsconfig.json is very simple to set up and run, but without incremental builds and project references is normally slower)

1 Like

I’m working with react. Babel is set up on running create-react-app .

What’s your usecase for Rollup?

I forked and cloned a repo react-query. On starting the app, the error came up. Today is actually my first day hearing about Rollup.