Typescript plugin 4.0.0 Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
See original GitHub issue- Rollup Plugin Name: typescript
- Rollup Plugin Version: 4.0.0
- Rollup Version: 2.2.0
- Operating System (or Browser): macOsx
- Node Version: 10.16.3
How Do We Reproduce?
import tsPlugin from '@rollup/plugin-typescript';
import pkg from './package.json';
export default {
input: 'src/index.tsx',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
},
],
plugins: [
tsPlugin(),
],
};
Expected Behavior
src/index.tsx → dist/index.js, dist/index.es.js...
created dist/index.js, dist/index.es.js in 1.1s
Actual Behavior
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/index.tsx (1:25)
1: export function hasan(num: number): number {
^
I hope I’m doing something wrong because it is so bad to cant use ts plugin. Ts plugin version 3.0.0 works perfect by the way.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:136
- Comments:65 (15 by maintainers)
Top Results From Across the Web
Unexpected token (Note that you need plugins to import files ...
Building Typescript: [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) ; config.js stderr ; config....
Read more >rollup/plugin-typescript/README.md - UNPKG
168, [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript). 169, file.tsx (1:15).
Read more >@rollup/plugin-typescript - npm package | Snyk
Error : Unexpected token (Note that you need plugins to import files that are not JavaScript) file.tsx (1:15) 1: export default <span>Foobar</span> ^....
Read more >@rollup/plugin-typescript - npm
Seamless integration between Rollup and TypeScript. ... Start using @rollup/plugin-typescript in your project by running `npm i ...
Read more >Getting a TypeScript enum in a standalone file to play nice ...
The error message is telling you that you need a plugin that can handle .ts files, so you need to add the typescript...
Read more >
Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top Related StackOverflow Question
Quick fix for now is to manually set your rootDir compiler option to “src”.
@talentlessguy I resolved this problem by removing
outDir,declarationDir,declarationfromtsconfig.json. If you need them when you invoketsc, specify them using command line arguments.