Skip to content

[Bug]: jsxFactory设置为了h ,但是编译后的文件依然使用了React.createElement #574

@NexxLuo

Description

@NexxLuo

Version

windows 10;
Chrome;
@rslib/core 0.1.3;

Details

  1. tsconfig.json配置如下:
{
   "extends": "../../tsconfig.json",
   "compilerOptions": {
     "jsxFactory": "h",
     "rootDir": "src",
     "isolatedModules":true,
     "declaration": true
   },
   "include": ["src"]
 }
 
  1. 项目中使用vue2以及jsx编写组件,使用pluginVue2、pluginVue2Jsx对文件进行编译,编译后的文件使用了React.createElement而不是h函数
  2. rslib.config.ts配置:
import { defineConfig } from "@rslib/core";
import { pluginSass } from "@rsbuild/plugin-sass";
import { pluginVue2 } from "@rsbuild/plugin-vue2";
import { pluginVue2Jsx } from "@rsbuild/plugin-vue2-jsx";

export default defineConfig({
  plugins: [pluginSass(),pluginVue2(),pluginVue2Jsx()],
  lib: [
    {
      source: {
        entry: {
          index: "./src/**",
        },
      },
      format: "cjs",
      bundle: false,
      autoExternal:false,
      dts: { bundle: false, distPath: "./lib", build: false, abortOnError: false },
      //dts:false
    }
  ],
  output: {
    target: "web",
    distPath: {
      root: "./lib",
    },
  }
});
  1. 源文件及编译后的文件内容如下:
    源文件:
    Image

编译后的结果:

Image

Reproduce link

https://github.com/NexxLuo/rslib-demo.git

Reproduce Steps

  1. yarn install
  2. npm run build
  3. 查看packages/packages-a/lib/ComponentA.js,文件中错误使用了React.createElement

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions