When I try to bundle that package, I get an error:
src/index.tsx → ./build...
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/MyComponent.tsx (4:33)
2: import { add } from '@project/utils';
3:
4: export const MyComponent = () => <div>{add(2, 2)}</div>;
^
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
I created a branch on a simple example repo to show this issue. Note that it is branch
babel
in that repo to reproduce the issue below.I have a lerna monorepo.
It has a packages directory, and one of the packages there is called
component-library
, containing a simple React component.That package has a
rollup.config.js
:When I try to bundle that package, I get an error:
My .babelrc looks like this:
Why do I have this error? Doesn't babel with @babel/preset-react handle JSX?