3

I have a Next.js app A with only Typescript files and a package B with this index.tsx file:

export default () => {
    console.log('hi');
}

When I import it in any file of my Next.js app A by doing:

import f from 'B';

I get this error:

ModuleParseError: Module parse failed: Unexpected token (15:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

that seems related to Webpack but I have no idea how to solve it.

Lucas Willems
  • 6,673
  • 4
  • 28
  • 45

1 Answers1

0

You can add transpilePackages: ['package-name'], into your next.config.js starting from 13.0 version https://nextjs.org/docs/app/api-reference/next-config-js/transpilePackages If you're using older version of next.js, you can use this package, but it's deprecated