Skillpedia
برمجة عامة75k · #2836

es-modules

ما الذي تفعله

تراجع هذه المهارة ملفات JavaScript التي تستخدم صيغة الوحدات القديمة وتقترح المعيار الحديث. وهي موجهة إلى المطورين الذين يريدون كودًا أخف وأوضح.

متى تستخدمها

  • ✓عندما لا تزال ملفات JavaScript تستخدم require() أو module.exports.
  • ✓عندما تتضمن حزمتك كودًا لا تستخدمه أبدًا.
  • ✓عندما تريد أن تُحمَّل سكربتاتك كوحدات أصلية في المتصفح.

رابط المهارة

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/es-modules/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/es-modules/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“هل يمكنك تحويل عبارات require في ملف JavaScript الخاص بي إلى صيغة import؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يجد الوكيل أسطر require وmodule.exports ويقترح عبارات import وexport مطابقة. ويوصي بالتصدير المسمّى حيث يناسب ذلك.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Use ES modules (import/export)

ES modules are statically analyzable — bundlers can determine at build time what code is actually used and eliminate the rest (tree-shaking). CommonJS require() is dynamic and prevents this optimization. ES modules are also the browser-native standard, reducing the need for build-time transformation.

Quick Reference

  • Use import/export syntax instead of require()/module.exports
  • Named exports improve IDE autocompletion and enable tree-shaking
  • Add type="module" to script tags or use a bundler to load ES modules in browsers
  • Default exports are fine but named exports scale better in large codebases

Check

Identify any use of require(), module.exports, or exports in this JavaScript file that should be converted to ES module syntax.

Fix

Convert all require() and module.exports statements to ES module import/export syntax.

Explain

Explain the benefits of ES modules over CommonJS, including tree-shaking, static analysis, and browser support.

Code Review

Review scripts, client components, and browser execution paths related to Use ES modules (import/export). Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/es-modules

الأسئلة الشائعة

ما هو tree-shaking؟

هو أن تزيل أداة التجميع الكود الذي لا يُستخدم أبدًا، فتصبح الملفات أصغر. وصيغة الوحدات الحديثة تجعل ذلك ممكنًا.

هل أستخدم التصدير المسمّى؟

تقول المهارة إن التصدير المسمّى يتوسع بشكل أفضل في قواعد الكود الكبيرة، وإن التصدير الافتراضي ما زال مقبولًا.

كيف أحمّل الوحدات في المتصفح؟

تقترح المهارة إضافة type=module إلى وسم السكربت، أو استخدام أداة تجميع.

التفاصيل

الوصف الأصلي من المؤلف

Use when reviewing scripts, client components, bundles, or runtime behavior related to Use ES modules (import/export). Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

الشعبية

نجوم GitHub
75k
الترتيب
#2836
الترخيص
MIT
آخر تحديث
31‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة