I'm currently facing some unexpected challenges while attempting to extract a small portion of a monorepo into a web client library. The issue seems to be related to the configuration of Rollup, as shown below:
import resolve from "rollup-plugin-node-resolve";
import typescript from "rollup-plugin-typescript2";
import sourceMaps from 'rollup-plugin-sourcemaps';
export default {
input: "../main.ts",
output: {
file: './bundle/rollup-bundle.js',
format: 'iife',
name: 'WebClient',
sourcemap: true
},
plugins: [
typescript(),
resolve({browser: true, mainFields: ['module']}),
sourceMaps(),
]
};
This setup generates the following error message:
../main.ts → ./bundle/rollup-bundle.js...
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
..\main.ts (3:32)
1: [...]
2:
3: export const createClient = (url: string) => new ClientImpl([...]);
^
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
It appears that the rollup-plugin-typescript2
is not properly transpiling TypeScript code, which seems like a very basic task. I am quite puzzled by this issue!
Any help or insights would be greatly appreciated. Thank you!