reactjs - ตัวเลือกเกิดข้อผิดพลาด TS5089: ไม่สามารถระบุตัวเลือก 'jsxFactory' ได้เมื่อกำหนดตัวเลือก 'jsx' เป็น 'react-jsx'
ฉันมีหน้า React สาธารณะหรือคอมโพเนนต์ที่ต้องการแชร์คอมโพเนนต์เหล่านี้ไปทั่วทั้งโปรเจกต์ เป็นไปได้ไหมที่จะแชร์? ฉันกำลังพยายามใช้ Microbundle ในการทำ ดูเหมือนว่าเครื่องมือนี้สามารถแชร์แค่ไลบรารี ts เท่านั้น ฉันได้เพิ่มการกำหนดค่าแพ็กเกจตาม https://github.com/developit/microbundle ดังนี้:
{
"name": "rd-component",
"type": "module",
"source": "src/index.tsx",
"exports": {
"require": "./dist/foo.cjs",
"default": "./dist/foo.modern.js"
},
"main": "./dist/foo.cjs",
"module": "./dist/foo.module.js",
"unpkg": "./dist/foo.umd.js",
"scripts": {
"build": "microbundle",
"dev": "microbundle watch"
},
"devDependencies": {
"microbundle": "^0.15.1"
}
}
เมื่อฉันคอมไพล์ แสดงข้อผิดพลาดแบบนี้:
rpt2: options error TS5089: Option 'jsxFactory' cannot be specified when option 'jsx' is 'react-jsx'.
rpt2: options error TS5089: Option 'jsxFragmentFactory' cannot be specified when option 'jsx' is 'react-jsx'.
(rpt2 plugin) Error: /Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/src/component/demo/CommonPage.tsx(1,19): semantic error TS2307: Cannot find module 'react' or its corresponding type declarations.
Error: /Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/src/component/demo/CommonPage.tsx(1,19): semantic error TS2307: Cannot find module 'react' or its corresponding type declarations.
at error (/Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/rollup/dist/shared/rollup.js:198:30)
at throwPluginError (/Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/rollup/dist/shared/rollup.js:21718:12)
at Object.error (/Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/rollup/dist/shared/rollup.js:22672:20)
at Object.error (/Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/rollup/dist/shared/rollup.js:21895:42)
at RollupContext.error (/Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20259:30)
at /Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29527:23
at Array.forEach (<anonymous>)
at printDiagnostics (/Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29500:17)
at Object.transform (/Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29785:17)
at /Users/xiaoqiangjiang/source/reddwarf/frontend/rd-component/node_modules/rollup/dist/shared/rollup.js:22879:40
เป็นไปได้ไหมที่จะแก้ไขปัญหานี้? ฉันได้ลองติดตั้ง Dependencies แล้ว:
npm install microbundle react react-dom --save-dev