การเรียกใช้และแก้ไขข้อบกพร่องของแอปแบบรวมภายในเครื่อง
เรียนรู้การเริ่มแอปโฮสต์และแอประยะไกลพร้อมกัน ตรวจสอบโมดูลแบบรวมในเบราว์เซอร์ และแก้ไขปัญหาทั่วไประหว่างการพัฒนาภายในเครื่อง
การเรียกใช้และแก้ไขข้อบกพร่องของแอปแบบรวมภายในเครื่อง เป็นบทเรียน Micro Frontends Architecture with Module Federation ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Micro Frontends Architecture with Module Federation และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Micro Frontends Architecture with Module Federation มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Local Development Setup
A federated app is really several apps. To develop, you run each remote and the host at the same time, each on its own port.
Assigning Ports
Give every app a fixed dev-server port so the host can reliably reference each remote during development.
devServer: { port: 3001 } // remote
devServer: { port: 3000 } // hostRunning Everything at Once
Manually opening many terminals is tedious. A tool like concurrently starts all dev servers with one command.
"scripts": {
"dev": "concurrently \"npm:dev:host\" \"npm:dev:remote\""
}Pointing the Host at Remotes
During development the host references each remote by its dev-server URL plus the exposed entry file.
remotes: {
cart: "cart@http://localhost:3001/remoteEntry.js"
}Inspecting remoteEntry.js
Every remote exposes a remoteEntry.js manifest. Open it directly in the browser to confirm the remote is running and to see what modules it exposes.
Using Browser DevTools
In the Network tab, watch for remoteEntry.js and the exposed module chunks loading. A 404 here is the most common federation error.
Common Error: Module Not Found
The error Cannot find module cart/Widget usually means the exposed path in the remote config does not match what the host imports. Names must match exactly.
exposes: { "./Widget": "./src/Widget" } // remote
import Widget from "cart/Widget"; // hostCommon Error: Shared React Twice
If React hooks throw Invalid hook call, two React copies are loading. Confirm singleton: true on React in every app config.
Hot Reload Limitations
Changes inside a remote may not hot-reload in the host automatically. Refresh the host, or restart the remote dev server, after editing exposed modules.
Logging Federation Resolution
Set verbose webpack stats or add console logs in your bootstrap to confirm which remote and shared versions resolved at run time.
console.log("loading remote cart...");
import("cart/Widget").then(m => mount(m.default));A Local Debug Checklist
When something breaks, check in order:
- Are all dev servers running?
- Does
remoteEntry.jsload (no 404)? - Do exposed names match imports?
- Is React a singleton everywhere?
Quick Check
Test your local debugging knowledge.
Recap
You learned to run and debug federated apps locally:
- Run host and remotes together on fixed ports
- Use
concurrentlyfor one-command startup - Inspect
remoteEntry.jsand the Network tab - Fix module-not-found and double-React errors
- Follow a quick debug checklist
Smooth local debugging speeds up MFE development.
เรียนรู้ JavaScript ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “การเรียกใช้และแก้ไขข้อบกพร่องของแอปแบบรวมภายในเครื่อง” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การเรียกใช้และแก้ไขข้อบกพร่องของแอปแบบรวมภายในเครื่อง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Micro Frontends Architecture with Module Federation ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Micro Frontends Architecture with Module Federation มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การเรียกใช้และแก้ไขข้อบกพร่องของแอปแบบรวมภายในเครื่อง”
เรียนรู้การเริ่มแอปโฮสต์และแอประยะไกลพร้อมกัน ตรวจสอบโมดูลแบบรวมในเบราว์เซอร์ และแก้ไขปัญหาทั่วไประหว่างการพัฒนาภายในเครื่อง คุณปฏิบัติ Micro Frontends Architecture with Module Federation ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Micro Frontends Architecture with Module Federation หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Micro Frontends Architecture with Module Federation บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “การเรียกใช้และแก้ไขข้อบกพร่องของแอปแบบรวมภายในเครื่อง” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Micro Frontends Architecture with Module Federation นี้ได้ไหม
ได้ บทเรียน Micro Frontends Architecture with Module Federation ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การตั้งค่าโครงการและการกำหนดค่า
- การแชร์โมดูลและคอมโพเนนต์
- การสร้างแอปแบบสหพันธ์อย่างง่าย
- การเรียกใช้และแก้ไขข้อบกพร่องของแอปแบบรวมภายในเครื่อง