繁体   English   中英

next.js 与 Turborepo ui package 通过错误导入:您可能需要合适的加载程序

[英]next js with Turborepo ui package import through error: You may need an appropriate loader

我正在使用 next.js 13.1.1 并且第一次使用turborepo配置基于 monoRepo 的项目。 我想用

  • @next/捆绑分析器
  • @哨兵/nextjs
  • @next-pwa

没有上述配置一切正常

const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  poweredByHeader: false,
  compress: true,
  transpilePackages: ['ui']
}
module.exports = nextConfig

但是如果我使用下面的代码

module.exports = withNextPwa(withBundleAnalyzer(
  withSentryConfig({
    nextConfig,
    sentryWebpackPluginOptions,
  })
));

出现错误

../../packages/ui/components/Button.tsx
Module parse failed: Unexpected token (4:28)
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
import { ButtonProps } from "../type";
| 
> export const Button = (props:ButtonProps) => {
|   return <button>{props.label}</button>
| }

Import trace for requested module:
../../packages/ui/components/Button.tsx
../../packages/ui/index.tsx
./src/components/home/hero.tsx
./src/components/home/index.tsx

我已经花了一天多的时间来解决这个问题,但没有运气。 欢迎任何建议或指导提前致谢

我不知道为什么,但是当我添加 transpilePackages 甚至是空的时,它起作用了:

...
transpilePackages: []
...

一些错误?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM