You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Yarn构建失败:TS5052配置错误与Babel找不到../buildMatchMemberExpression模块问题

Troubleshooting Your Package Build Errors

Let's break down and fix the two build errors you're encountering when running yarn build for your @mypackage/ui-components package:

1. Resolving the TypeScript TS5052 Error

The error Option 'jsxFragmentFactory' cannot be specified without specifying option 'jsxFactory' points to a misconfiguration in your tsconfig.build.json file. Here's how to fix it:

  • For React 17+ automatic JSX transform:
    Open your tsconfig.build.json and update the compilerOptions section to use React's modern JSX handling:
    {
      "compilerOptions": {
        "jsx": "react-jsx",
        // Remove any explicit `jsxFragmentFactory` or `jsxFactory` entries
      }
    }
    
    React 17+ automatically imports JSX utilities, so those two options are no longer required and will cause conflicts if set.
  • If you need the legacy JSX transform:
    If you must use jsx: "react" in your config, you must define both options together:
    {
      "compilerOptions": {
        "jsx": "react",
        "jsxFactory": "React.createElement",
        "jsxFragmentFactory": "React.Fragment"
      }
    }
    

2. Fixing the Babel Cannot find module '../buildMatchMemberExpression' Error

This error usually comes from version mismatches between Babel core and your plugins, or an outdated microbundle version (since you're using microbundle to handle the build):

Option A: Upgrade Microbundle

Your current microbundle version (0.15.0) is outdated, which can cause compatibility issues with modern Babel and TypeScript releases. Update it in your package.json:

{
  "devDependencies": {
    "microbundle": "^0.15.1" // Or the latest stable version available on npm
  }
}

Run yarn install to fetch the updated package after making this change.

Option B: Align Babel Plugin Versions

If upgrading microbundle doesn't resolve the issue, verify your Babel plugins are compatible with @babel/core@7.16.0:

  • The babel-plugin-dynamic-import-node version you're using (2.3.3) may be outdated. Try upgrading it to ^2.3.4 or the latest compatible release.
  • Ensure all your Babel presets (@babel/preset-env, @babel/preset-react) match the minor version of @babel/core (7.16.x) to avoid compatibility gaps.

Extra Checks

  • Confirm there are no conflicting TypeScript/Babel configurations in parent directories (like a root tsconfig.json or .babelrc) that override your package-specific settings.
  • After making changes, run yarn clean followed by yarn build to eliminate any cached artifacts that might be causing issues.

Quick Cleanup Note

I noticed classnames is listed in both dependencies and devDependencies—you can safely remove the entry in devDependencies to eliminate redundancy.

内容的提问来源于stack exchange,提问作者Ludwig

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 21:57:42