简体   繁体   English

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

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

I'm working with next.js 13.1.1 and first time configuring a monoRepo-based project using turborepo .我正在使用 next.js 13.1.1 并且第一次使用turborepo配置基于 monoRepo 的项目。 and I want to use我想用

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

without the above config everything works perfectly没有上述配置一切正常

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

but if I use below code但是如果我使用下面的代码

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

getting error出现错误

../../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

I have already spent more than one day to solve this but no-luck.我已经花了一天多的时间来解决这个问题,但没有运气。 any suggestion or guidance is welcome thanks in advance欢迎任何建议或指导提前致谢

I dont know why, but when I add transpilePackages even empty, it works:我不知道为什么,但是当我添加 transpilePackages 甚至是空的时,它起作用了:

...
transpilePackages: []
...

Some bug?一些错误?

暂无
暂无

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

相关问题 js错误:您可能需要适当的加载器 - js error: You may need an appropriate loader Turborepo - 使用另一个库的库 - 您可能需要适当的加载器来处理此文件类型 - Turborepo - library consuming another library - You may need an appropriate loader to handle this file type ReactJS-您可能需要适当的加载程序错误 - ReactJS - You May Need an Appropriate Loader Error 尝试将 JSON 导入 React 组件时出错:“您可能需要一个合适的加载器”,但正确的加载器已经安装 - Error when attempting to import JSON into a React component: "You may need an appropriate loader", but the correct loader is already installed 无法导入模块:您可能需要一个合适的加载器 - Can not import module: You may need an appropriate loader SVG Next Error 你可能需要一个合适的加载器来处理这个文件类型,目前没有加载器被配置来处理这个文件 - SVG Next Error You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file 错误:您可能需要合适的加载程序来处理此文件类型 - Error: You may need an appropriate loader to handle this file type webpack错误-您可能需要适当的加载程序来处理此文件类型 - error with webpack - You may need an appropriate loader to handle this file type Webpack 错误:您可能需要合适的加载程序来处理此文件类型 - Webpack error: You may need an appropriate loader to handle this file type Webpack 错误 - 您可能需要适当的加载器来处理此文件类型, - Webpack Error - You may need an appropriate loader to handle this file type,
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM