From bf1023dc1e2246620e9768de6f1e99a1946e6927 Mon Sep 17 00:00:00 2001 From: !? ReLaX <133292635+RlxChap2@users.noreply.github.com> Date: Tue, 19 May 2026 04:15:24 +0300 Subject: [PATCH 01/35] feat(arabic): initialize Arabic translation Translate initial blog and configuration index content to Arabic while preserving MDX structure. Co-authored-by: ameencfw Co-authored-by: Shimizu Hiroyuki --- .../blog/2020-10-10-webpack-5-release.mdx | 1739 ++++++++--------- src/content/blog/2020-12-08-roadmap-2021.mdx | 275 +-- src/content/blog/2026-02-03-webpack-5-105.mdx | 137 +- src/content/blog/2026-02-04-roadmap-2026.mdx | 161 +- src/content/blog/2026-04-08-webpack-5-106.mdx | 153 +- src/content/blog/index.mdx | 9 +- .../configuration/configuration-languages.mdx | 76 +- src/content/configuration/index.mdx | 41 +- 8 files changed, 1281 insertions(+), 1310 deletions(-) diff --git a/src/content/blog/2020-10-10-webpack-5-release.mdx b/src/content/blog/2020-10-10-webpack-5-release.mdx index 980e688ab7a2..29c1638ad42c 100644 --- a/src/content/blog/2020-10-10-webpack-5-release.mdx +++ b/src/content/blog/2020-10-10-webpack-5-release.mdx @@ -2,326 +2,326 @@ title: Webpack 5 release sort: 20201010 contributors: - - sokra - - chenxsan + - ameencfw + - RlxChap2 --- -Webpack 4 was released in February 2018. -Since then we shipped a lot of features without breaking changes. -We know that people dislike major changes with breaking changes. -Especially with webpack, which people usually only touch twice a year, and the remaining time it "just works". -But shipping features without breaking changes also has a cost: -We can't do major API or architectural improvements. +تم إصدار Webpack 4 في فبراير 2018. +منذ ذلك الحين قمنا بشحن الكثير من المميزات دون إحداث تغييرات جذرية (breaking changes). +نحن نعلم أن الناس يكرهون التغييرات الكبيرة التي تصاحبها تغييرات جذرية. +خاصة مع webpack، الذي عادة ما يتعامل معه الناس مرتين فقط في السنة، وفي بقية الوقت "يعمل ببساطة". +لكن شحن الميزات دون تغييرات جذرية له تكلفة أيضًا: +لا يمكننا إجراء تحسينات كبيرة على واجهة برمجة التطبيقات (API) أو البنية المعمارية. -So from time to time, there is a point where the difficulties pile up and we are forced to do breaking changes to not mess everything up. -That's the time for a new major version. -So webpack 5 contains these architectural improvements and the features that were not possible to implement without them. +لذا من وقت لآخر، نصل إلى نقطة تتراكم فيها الصعوبات ونُجبر على إجراء تغييرات جذرية لتجنب إفساد كل شيء. +هذا هو الوقت المناسب لإصدار رئيسي جديد (major version). +لذلك يحتوي webpack 5 على هذه التحسينات المعمارية والميزات التي لم يكن من الممكن تنفيذها بدونها. -The major version was also the chance to revise some of the defaults and to align with proposals and specifications that come up in the meantime. +كان الإصدار الرئيسي أيضًا فرصة لمراجعة بعض الإعدادات الافتراضية ومواءمتها مع المقترحات والمواصفات التي ظهرت في غضون ذلك. -So today (2020-10-10) webpack 5.0.0 is released, but this doesn't mean it's done, bugfree or even feature-complete. -As with webpack 4 we continue development by fixing problems and adding features. -In the next days there will probably be a lot bugfixes. Features will come later. +لذا تم اليوم (2020-10-10) إطلاق webpack 5.0.0، لكن هذا لا يعني أنه مكتمل، أو خالٍ من الأخطاء، أو حتى مكتمل الميزات. +كما حدث مع webpack 4، نواصل التطوير من خلال إصلاح المشاكل وإضافة الميزات. +في الأيام القادمة من المحتمل أن يكون هناك الكثير من إصلاحات الأخطاء. ستأتي الميزات لاحقًا. -## Common Questions +## أسئلة شائعة -### So what does the release mean? +### إذن ماذا يعني هذا الإصدار؟ -It means we finished doing breaking changes. -Many refactorings have been done to up-level the architecture and create a good base for future features (and current features). +يعني أننا انتهينا من إجراء التغييرات الجذرية. +تم إجراء العديد من عمليات إعادة الهيكلة (refactoring) لرفع مستوى البنية وإنشاء قاعدة جيدة للميزات المستقبلية (والميزات الحالية). -### So when is the time to upgrade? +### إذن متى يحين وقت الترقية؟ -It depends. There is a good chance that upgrading fails and you would need to give it a second or 3rd try. -If you are open to that, try to upgrade now and provide feedback to webpack, plugins and loaders. -We are eager to fix those problems. Someone has to start and you would be one of the first ones benefiting from it. +يعتمد الأمر. هناك فرصة جيدة أن تفشل الترقية وقد تحتاج إلى المحاولة للمرة الثانية أو الثالثة. +إذا كنت منفتحًا على ذلك، فحاول الترقية الآن وقدم ملاحظاتك إلى webpack والإضافات (plugins) والمحملات (loaders). +نحن حريصون على إصلاح تلك المشاكل. يجب أن يبدأ شخص ما وستكون أنت من أوائل المستفيدين منه. -## Sponsoring Update +## تحديث الرعاية (Sponsoring Update) -Webpack is fully based upon [sponsoring](https://opencollective.com/webpack). -It's not tied to (and paid by) a big company like some other Open Source projects. -99% of the earnings from sponsoring are distributed towards contributors and maintainers based on the contributions they do. -We believe in investing the money towards making webpack better. +يعتمد Webpack بالكامل على [الرعاية](https://opencollective.com/webpack). +إنه غير مرتبط (أو مدفوع الأجر) بشركة كبيرة مثل بعض مشاريع المصادر المفتوحة الأخرى. +يتم توزيع 99% من أرباح الرعاية على المساهمين والمشرفين بناءً على المساهمات التي يقومون بها. +نحن نؤمن باستثمار الأموال نحو جعل webpack أفضل. -But there is a pandemic, and companies ain't that much open to sponsoring anymore. -Webpack is suffering under these circumstances too (like many other companies and people). +ولكن هناك جائحة، والشركات لم تعد منفتحة كثيرًا على الرعاية كما كانت. +يعاني Webpack في ظل هذه الظروف أيضًا (مثل العديد من الشركات والأشخاص الآخرين). -We were never able to pay our contributors the amount we think they deserve, but now we only have half of the money available, so we need to make a more serious cut. -Until the situation improves we will only pay contributors and maintainers the first 10 days of each month. -The remaining days they could work voluntarily, paid by their employer, work on something else, or take some days off. -This allows us to pay for their work in the first 10 days more equivalent to the invested time. +لم نتمكن أبدًا من الدفع لمساهمينا المبلغ الذي نعتقد أنهم يستحقونه، ولكن الآن ليس لدينا سوى نصف الأموال المتاحة، لذا نحن بحاجة إلى إجراء خفض أكثر جدية. +حتى يتحسن الوضع، سندفع فقط للمساهمين والمشرفين عن الأيام العشرة الأولى من كل شهر. +أما الأيام المتبقية فيمكنهم العمل بشكل تطوعي، أو بأجر من صاحب عملهم، أو العمل على شيء آخر، أو أخذ بعض أيام الإجازة. +يتيح لنا ذلك الدفع مقابل عملهم في الأيام العشرة الأولى بما يعادل بشكل أكبر الوقت المستثمر. -The biggest "Thank You" goes to [trivago](https://tech.trivago.com/opensource) which has been sponsoring webpack a huge amount for the last 3 years. -Sadly they are unable to continue their sponsorship this year, as they have been hit hard by Covid-19. -I hope some other company steps up and follows these (gigantic) footsteps. +أكبر كلمة "شكرًا" تذهب إلى [trivago](https://tech.trivago.com/opensource) التي كانت ترعى webpack بمبلغ ضخم على مدار السنوات الثلاث الماضية. +للأسف هم غير قادرين على الاستمرار في رعايتهم هذا العام، حيث تضرروا بشدة من Covid-19. +آمل أن تتقدم شركة أخرى وتحذو حذو هذه الخطوات (العملاقة). -Thanks to [all the sponsors](/#sponsors). +شكرًا لـ [جميع الرعاة](/#sponsors). -## General direction +## الاتجاه العام -This release focus on the following: +يركز هذا الإصدار على ما يلي: -- Improve build performance with Persistent Caching. -- Improve Long Term Caching with better algorithms and defaults. -- Improve bundle size with better Tree Shaking and Code Generation. -- Improve compatibility with the web platform. -- Clean up internal structures that were left in a weird state while implementing features in v4 without introducing any breaking changes. -- Prepare for future features by introducing breaking changes now, allowing us to stay on v5 for as long as possible. +- تحسين أداء البناء باستخدام التخزين المؤقت المستمر (Persistent Caching). +- تحسين التخزين المؤقت طويل المدى (Long Term Caching) بخوارزميات وافتراضيات أفضل. +- تحسين حجم الحزمة (bundle size) بفضل Tree Shaking وتوليد أكواد أفضل. +- تحسين التوافق مع منصة الويب. +- تنظيف الهياكل الداخلية التي تُركت في حالة غريبة أثناء تنفيذ الميزات في الإصدار 4 دون إدخال أي تغييرات جذرية. +- التحضير للميزات المستقبلية عن طريق إدخال تغييرات جذرية الآن، مما يسمح لنا بالبقاء على الإصدار 5 لأطول فترة ممكنة. -## **Migration** Guide +## دليل **الترحيل** (Migration Guide) -[See here for a **migration** guide](/migrate/5) +[انظر هنا للحصول على دليل **الترحيل**](/migrate/5) -## Major Changes: Removals +## تغييرات رئيسية: الإزالات -### Removed Deprecated Items +### إزالة العناصر المهملة (Deprecated Items) -All items deprecated in v4 were removed. +تمت إزالة جميع العناصر التي تم إهمالها في الإصدار 4. -**MIGRATION**: Make sure that your webpack 4 build does not print deprecation warnings. +**الترحيل**: تأكد من أن بناء webpack 4 الخاص بك لا يطبع تحذيرات الإهمال (deprecation warnings). -Here are a few things that were removed but did not have deprecation warnings in v4: +إليك بعض الأشياء التي تمت إزالتها ولكن لم تكن تحتوي على تحذيرات إهمال في الإصدار 4: -- IgnorePlugin and BannerPlugin must now be passed only one argument that can be an object, string or function. +- يجب الآن تمرير وسيط واحد فقط لـ IgnorePlugin و BannerPlugin، يمكن أن يكون كائنًا (object)، أو سلسلة نصية (string)، أو دالة (function). -### Deprecation codes +### رموز الإهمال (Deprecation codes) -New deprecations include a deprecation code so they are easier to reference. +تتضمن الإهمالات الجديدة رمز إهمال بحيث يسهل الإشارة إليها. -### Syntax deprecated +### بنية جمل مهملة (Syntax deprecated) -`require.include` has been deprecated and will emit a warning by default when used. +تم إهمال `require.include` وسيصدر تحذيرًا بشكل افتراضي عند استخدامه. -Behavior can be changed with `Rule.parser.requireInclude` to allowed, deprecated or disabled. +يمكن تغيير السلوك باستخدام `Rule.parser.requireInclude` إلى مسموح به (allowed)، مهمل (deprecated)، أو معطل (disabled). -### Automatic Node.js Polyfills Removed +### إزالة تعويضات Node.js التلقائية (Automatic Node.js Polyfills Removed) -In the early days, webpack's aim was to allow running most Node.js modules in the browser, but the module landscape changed and many module uses are now written mainly for frontend purposes. Webpack <= 4 ships with polyfills for many of the Node.js core modules, which are automatically applied once a module uses any of the core modules (i.e. the `crypto` module). +في الأيام الأولى، كان هدف webpack هو السماح بتشغيل معظم وحدات Node.js في المتصفح، ولكن المشهد تغير وأصبحت العديد من الوحدات تُكتب الآن بشكل أساسي لأغراض الواجهة الأمامية. يأتي Webpack <= 4 مع تعويضات (polyfills) للعديد من الوحدات الأساسية لـ Node.js، والتي يتم تطبيقها تلقائيًا بمجرد استخدام أي وحدة من الوحدات الأساسية (مثل وحدة `crypto`). -While this makes using modules written for Node.js easier, it adds these huge polyfills to the bundle. In many cases these polyfills are unnecessary. +في حين أن هذا يجعل استخدام الوحدات المكتوبة لـ Node.js أسهل، إلا أنه يضيف هذه التعويضات الضخمة إلى الحزمة. في كثير من الحالات، تكون هذه التعويضات غير ضرورية. -Webpack 5 stops automatically polyfilling these core modules and focus on frontend-compatible modules. Our goal is to improve compatibility with the web platform, where Node.js core modules are not available. +يتوقف Webpack 5 عن إضافة التعويضات لهذه الوحدات الأساسية تلقائيًا ويركز على الوحدات المتوافقة مع الواجهة الأمامية. هدفنا هو تحسين التوافق مع منصة الويب، حيث لا تتوفر الوحدات الأساسية لـ Node.js. -**MIGRATION**: +**الترحيل**: -- Try to use frontend-compatible modules whenever possible. -- It's possible to manually add a polyfill for a Node.js core module. An error message will give a hint on how to achieve that. -- Package authors: Use the `browser` field in `package.json` to make a package frontend-compatible. Provide alternative implementations/dependencies for the browser. +- حاول استخدام الوحدات المتوافقة مع الواجهة الأمامية كلما أمكن ذلك. +- من الممكن إضافة تعويض (polyfill) يدويًا لوحدة أساسية في Node.js. ستعطي رسالة الخطأ تلميحًا حول كيفية تحقيق ذلك. +- لمؤلفي الحزم: استخدم حقل `browser` في `package.json` لجعل الحزمة متوافقة مع الواجهة الأمامية. قدم تطبيقات/تبعيات (implementations/dependencies) بديلة للمتصفح. -## Major Changes: Long Term Caching +## تغييرات رئيسية: التخزين المؤقت طويل المدى (Long Term Caching) -### Deterministic Chunk, Module IDs and Export names +### الحزم، ومعرفات الوحدات، وأسماء الصادرات الحتمية (Deterministic) -New algorithms were added for long term caching. These are enabled by default in production mode. +تمت إضافة خوارزميات جديدة للتخزين المؤقت طويل المدى. تم تمكينها بشكل افتراضي في وضع الإنتاج (production mode). `chunkIds: "deterministic"` `moduleIds: "deterministic"` `mangleExports: "deterministic"` -The algorithms assign short (3 or 5 digits) numeric IDs to modules and chunks and short (2 characters) names to exports in a deterministic way. -This is a trade-off between bundle size and long term caching. +تقوم الخوارزميات بتعيين معرفات رقمية قصيرة (3 أو 5 أرقام) للوحدات والحزم، وأسماء قصيرة (حرفان) للصادرات بطريقة حتمية (deterministic). +هذا يمثل مقايضة (trade-off) بين حجم الحزمة والتخزين المؤقت طويل المدى. -`moduleIds/chunkIds/mangleExports: false` disables the default behavior and one can provide a custom algorithm via plugin. Note that in webpack 4 `moduleIds/chunkIds: false` without custom plugin resulted in a working build, while in webpack 5 you must provide a custom plugin. +يقوم `moduleIds/chunkIds/mangleExports: false` بتعطيل السلوك الافتراضي ويمكن للمرء توفير خوارزمية مخصصة عبر إضافة (plugin). لاحظ أنه في webpack 4، كان استخدام `moduleIds/chunkIds: false` بدون إضافة مخصصة يؤدي إلى بناء يعمل، بينما في webpack 5 يجب عليك توفير إضافة مخصصة. -**MIGRATION**: Best use the default values for `chunkIds`, `moduleIds` and `mangleExports`. You can also opt-in to the old defaults `chunkIds: "size", moduleIds: "size", mangleExports: "size"`, this will generate smaller bundles, but invalidate them more often for caching. +**الترحيل**: من الأفضل استخدام القيم الافتراضية لـ `chunkIds` و `moduleIds` و `mangleExports`. يمكنك أيضًا اختيار الافتراضيات القديمة `chunkIds: "size", moduleIds: "size", mangleExports: "size"`، سيؤدي هذا إلى إنشاء حزم أصغر، ولكنه سيبطل صلاحيتها (invalidate) بشكل متكرر عند التخزين المؤقت. -Note: In webpack 4 hashed module ids yielded reduced gzip performance. This was related to changed module order and has been fixed. +ملاحظة: في webpack 4، أدت معرفات الوحدات المجزأة (hashed module ids) إلى انخفاض أداء gzip. كان هذا مرتبطًا بتغير ترتيب الوحدات وتم إصلاحه. -Note: In webpack 5, `deterministic` Ids are enabled by default in production mode +ملاحظة: في webpack 5، تم تفعيل المعرفات `deterministic` بشكل افتراضي في وضع الإنتاج. -### Real Content Hash +### التجزئة الحقيقية للمحتوى (Real Content Hash) -Webpack 5 will use a real hash of the file content when using `[contenthash]` now. Before it "only" used a hash of the internal structure. -This can be positive impact on long term caching when only comments are changed or variables are renamed. These changes are not visible after minimizing. +سيستخدم Webpack 5 تجزئة (hash) حقيقية لمحتوى الملف عند استخدام `[contenthash]` الآن. في السابق كان يستخدم "فقط" تجزئة للبنية الداخلية. +يمكن أن يكون لهذا تأثير إيجابي على التخزين المؤقت طويل المدى عندما يتم تغيير التعليقات فقط أو إعادة تسمية المتغيرات. هذه التغييرات غير مرئية بعد التصغير (minimizing). -## Major Changes: Development Support +## تغييرات رئيسية: دعم التطوير (Development Support) -### Named Chunk IDs +### معرفات الحزم المسماة (Named Chunk IDs) -A new named chunk id algorithm enabled by default in development mode gives chunks (and filenames) human-readable names. -A Module ID is determined by its path, relative to the `context`. -A Chunk ID is determined by the chunk's content. +تم تمكين خوارزمية جديدة لمعرف الحزمة المسمى بشكل افتراضي في وضع التطوير (development mode) لمنح الحزم (وأسماء الملفات) أسماء قابلة للقراءة البشرية. +يتم تحديد معرف الوحدة (Module ID) من خلال مسارها بالنسبة إلى الـ `context`. +يتم تحديد معرف الحزمة (Chunk ID) من خلال محتوى الحزمة. -So you no longer need to use `import(/* webpackChunkName: "name" */ "module")` for debugging. -But it would still make sense if you want to control the filenames for production environments. +لذلك لم تعد بحاجة إلى استخدام `import(/* webpackChunkName: "name" */ "module")` لأغراض تصحيح الأخطاء (debugging). +ولكن سيظل من المنطقي استخدامها إذا كنت ترغب في التحكم في أسماء الملفات لبيئات الإنتاج. -It's possible to use `chunkIds: "named"` in production, but make sure not to accidentally expose sensitive information about module names. +من الممكن استخدام `chunkIds: "named"` في الإنتاج، ولكن تأكد من عدم الكشف عن معلومات حساسة حول أسماء الوحدات عن طريق الخطأ. -**MIGRATION**: If you dislike the filenames being changed in development, you can pass `chunkIds: "natural"` to use the old numeric mode. +**الترحيل**: إذا كنت تكره تغيير أسماء الملفات في التطوير، يمكنك تمرير `chunkIds: "natural"` لاستخدام الوضع الرقمي القديم. ### Module Federation -Webpack 5 adds a new feature called "Module Federation", which allows multiple webpack builds to work together. -From runtime perspective modules from multiple builds will behave like a huge connected module graph. -From developer perspective modules can be imported from specified remote builds and used with minimal restrictions. +يضيف Webpack 5 ميزة جديدة تسمى "Module Federation"، والتي تسمح لعدة بنيات (builds) webpack بالعمل معًا. +من منظور وقت التشغيل (runtime)، ستتصرف الوحدات من عمليات البناء المتعددة وكأنها رسم بياني متصل ضخم للوحدات. +من منظور المطور، يمكن استيراد الوحدات من عمليات بناء بعيدة (remote) محددة واستخدامها بأقل قدر من القيود. -For more details see [this separate guide](/concepts/module-federation). +لمزيد من التفاصيل انظر [هذا الدليل المنفصل](/concepts/module-federation). -## Major Changes: New Web Platform Features +## تغييرات رئيسية: ميزات منصة الويب الجديدة -### JSON modules +### وحدات JSON (JSON modules) -JSON modules now align with the proposal and emit a warning when a non-default export is used. -JSON modules no longer have named exports when importing from a strict ECMAScript module. +تتوافق وحدات JSON الآن مع الاقتراح وتصدر تحذيرًا عند استخدام تصدير غير افتراضي (non-default export). +لم يعد لوحدات JSON صادرات مسماة (named exports) عند الاستيراد من وحدة ECMAScript صارمة. -**MIGRATION**: Use the default export. +**الترحيل**: استخدم التصدير الافتراضي (`default export`). -Even when using the default export, unused properties are dropped by the `optimization.usedExports` optimization and properties are mangled by the `optimization.mangleExports` optimization. +حتى عند استخدام التصدير الافتراضي، يتم إسقاط الخصائص غير المستخدمة بواسطة تحسين `optimization.usedExports` ويتم تغيير الخصائص (mangled) بواسطة تحسين `optimization.mangleExports`. -It's possible to specify a custom JSON parser in `Rule.parser.parse` to import JSON-like files (e.g. for toml, yaml, json5, etc.). +من الممكن تحديد محلل JSON مخصص في `Rule.parser.parse` لاستيراد ملفات تشبه JSON (مثل toml، yaml، json5، إلخ). ### import.meta -- `import.meta.webpackHot` is an alias for `module.hot` which is also available in strict ESM -- `import.meta.webpack` is the webpack major version as number -- `import.meta.url` is the `file:` url of the current file (similar to `__filename` but as file url) +- `import.meta.webpackHot` هو اسم مستعار لـ `module.hot` المتاح أيضًا في ESM الصارم. +- `import.meta.webpack` هو الإصدار الرئيسي لـ webpack كـ رقم. +- `import.meta.url` هو رابط `file:` للملف الحالي (على غرار `__filename` ولكن كرابط ملف). -### Asset modules +### وحدات الأصول (Asset modules) -Webpack 5 has now native support for modules representing assets. -These modules will either emit a file into the output folder or inject a DataURI into the javascript bundle. -Either way they give a URL to work with. +يتمتع Webpack 5 الآن بدعم محلي للوحدات التي تمثل الأصول (assets). +ستقوم هذه الوحدات إما بإخراج ملف إلى مجلد المخرجات (output folder) أو حقن DataURI في حزمة javascript. +في كلتا الحالتين تمنحك رابط URL للعمل به. -They can be used via multiple ways: +يمكن استخدامها عبر طرق متعددة: -- `import url from "./image.png"` and setting `type: "asset"` in `module.rules` when matching such import. (old way) -- `new URL("./image.png", import.meta.url)` (new way) +- `import url from "./image.png"` وتعيين `type: "asset"` في `module.rules` عند مطابقة مثل هذا الاستيراد. (الطريقة القديمة) +- `new URL("./image.png", import.meta.url)` (الطريقة الجديدة) -The "new way" syntax was chosen to allow running code without bundler too. This syntax is also available in native ECMAScript modules in the browser. +تم اختيار بنية "الطريقة الجديدة" للسماح بتشغيل الكود بدون محزم (bundler) أيضًا. تتوفر هذه البنية أيضًا في وحدات ECMAScript المحلية في المتصفح. -### Native Worker support +### دعم Worker المحلي -When combining `new URL` for assets with `new Worker`/`new SharedWorker`/`navigator.serviceWorker.register` webpack will automatically create a new entrypoint for a web worker. +عند الجمع بين `new URL` للأصول مع `new Worker`/`new SharedWorker`/`navigator.serviceWorker.register` سيقوم webpack تلقائيًا بإنشاء نقطة دخول جديدة لـ web worker. `new Worker(new URL("./worker.js", import.meta.url))` -The syntax was chosen to allow running code without bundler too. This syntax is also available in native ECMAScript modules in the browser. +تم اختيار البنية للسماح بتشغيل الكود بدون محزم أيضًا. تتوفر هذه البنية أيضًا في وحدات ECMAScript المحلية في المتصفح. -### URIs +### المعرفات المنتظمة (URIs) -Webpack 5 supports handling of protocols in requests. +يدعم Webpack 5 التعامل مع البروتوكولات في الطلبات (requests). -- `data:` is supported. Base64 or raw encoding is supported. Mimetype can be mapped to loaders and module type in `module.rules`. Example: `import x from "data:text/javascript,export default 42"` -- `file:` is supported. -- `http(s):` is supported, but requires opt-in via `new webpack.experiments.schemesHttp(s)UriPlugin()` - - By default when targeting "web", these URIs result in requests to external resource (they are externals) +- `data:` مدعوم. يدعم تشفير Base64 أو الخام (raw). يمكن تعيين Mimetype للمحملات ونوع الوحدة في `module.rules`. مثال: `import x from "data:text/javascript,export default 42"` +- `file:` مدعوم. +- `http(s):` مدعوم، لكنه يتطلب التفعيل عبر `new webpack.experiments.schemesHttp(s)UriPlugin()` + - افتراضيًا عند استهداف "web"، تؤدي عناوين URI هذه إلى طلبات لموارد خارجية (وهي externals). -Fragments in requests are supported: Example: `./file.js#fragment` +الأجزاء (Fragments) في الطلبات مدعومة: مثال: `./file.js#fragment` -### Async modules +### الوحدات غير المتزامنة (Async modules) -Webpack 5 supports so called "async modules". -That are modules that do not evaluate synchronously, but are async and Promise-based instead. +يدعم Webpack 5 ما يسمى "الوحدات غير المتزامنة". +هي الوحدات التي لا يتم تقييمها بشكل متزامن، بل هي غير متزامنة وتعتمد على الوعود (Promise-based). -Importing them via `import` is automatically handled and no additional syntax is needed and difference is hardly notice-able. +يتم التعامل مع استيرادها عبر `import` تلقائيًا ولا يلزم وجود بنية إضافية والفرق بالكاد يمكن ملاحظته. -Importing them via `require()` will return a Promise that resolves to the exports. +استيرادها عبر `require()` سيعيد Promise يحل للصادرات (exports). -In webpack there are multiple ways to have async modules: +في webpack، هناك عدة طرق لامتلاك وحدات غير متزامنة: -- async externals -- WebAssembly Modules in the new spec -- ECMAScript Modules that are using Top-Level-Await +- externals غير متزامنة +- وحدات WebAssembly في المواصفات الجديدة +- وحدات ECMAScript التي تستخدم Top-Level-Await -### Externals +### الخارجيون (Externals) -Webpack 5 adds additional external types to cover more applications: +يضيف Webpack 5 أنواعًا إضافية للخارجيين لتغطية المزيد من التطبيقات: -`promise`: An expression that evaluates to a Promise. The external module is an async module and the resolved value is used as module exports. +`promise`: تعبير يتم تقييمه كـ Promise. الوحدة الخارجية هي وحدة غير متزامنة وتُستخدم القيمة التي تم حلها كصادرات للوحدة. -`import`: Native `import()` is used to load the specified request. The external module is an async module. +`import`: تُستخدم `import()` المحلية لتحميل الطلب المحدد. الوحدة الخارجية هي وحدة غير متزامنة. -`module`: Not implemented yet, but planned to load modules via `import x from "..."`. +`module`: لم يتم تنفيذها بعد، ولكن من المخطط تحميل الوحدات عبر `import x from "..."`. -`script`: Loads a url via ` @@ -945,9 +916,9 @@ Now the variable `MyLibrary` will be bound with the exports of your entry file, ``` -In the above example, we're passing a single entry file to `entry`, however, webpack can accept [many kinds of entry point](/configuration/entry-context/#entry), e.g., an `array`, or an `object`. +في المثال أعلاه، نقوم بتمرير ملف entry واحد إلى `entry`، ومع ذلك، يمكن أن يقبل webpack [العديد من أنواع entry point](/configuration/entry-context/#entry)، على سبيل المثال، `array`، أو `object`. -1. If you provide an `array` as the `entry` point, only the last one in the array will be exposed. +1. إذا قمت بتوفير `array` كنقطة `entry`، فسيتم عرض النقطة الأخيرة فقط في array. ```js export default { @@ -959,7 +930,7 @@ In the above example, we're passing a single entry file to `entry`, however, web }; ``` -2. If an `object` is provided as the `entry` point, all entries can be exposed using the `array` syntax of `library`: +2. إذا تم توفير `object` كنقطة `entry`، فيمكن كشف جميع الإدخالات باستخدام بناء جملة `array` لـ `library`: ```js export default { @@ -975,7 +946,7 @@ In the above example, we're passing a single entry file to `entry`, however, web }; ``` - Assuming that both `a.js` and `b.js` export a function `hello`, here's how to consume the libraries: +بافتراض أن كلا من `a.js` و`b.js` يقومان بتصدير function `hello`، فإليك كيفية استهلاك المكتبات: ```html @@ -986,9 +957,9 @@ In the above example, we're passing a single entry file to `entry`, however, web ``` - See [this example](https://github.com/webpack/webpack/tree/main/examples/multi-part-library) for more. +راجع [هذا المثال](https://github.com/webpack/webpack/tree/main/examples/multi-part-library) للمزيد. - Note that the above configuration won't work as expected if you're going to configure library options per entry point. Here is how to do it [under each of your entries](/concepts/entry-points/#entrydescription-object): +لاحظ أن التخصيص أعلاه لن يعمل كما هو متوقع إذا كنت ستقوم بتخصيص خيارات library لكل entry point. إليك كيفية القيام بذلك [تحت كل إدخال من إدخالاتك](/concepts/entry-points/#entrydescription-object): ```js export default { @@ -997,7 +968,7 @@ In the above example, we're passing a single entry file to `entry`, however, web main: { import: "./src/index.js", library: { - // all options under `output.library` can be used here + // يمكن استخدام جميع الخيارات ضمن `output.library` هنا name: "MyLibrary", type: "umd", umdNamedDefine: true, @@ -1018,9 +989,9 @@ In the above example, we're passing a single entry file to `entry`, however, web -Use a container(defined in global space) for calling `define`/`require` functions in an AMD module. +استخدم حاوية (محددة في المساحة العالمية) للاتصال بوظائف `define`/`require` في AMD module. -W> Note that the value of `amdContainer` **must be** set as a global variable. +W> لاحظ أنه يجب تعيين قيمة `amdContainer` **كمتغير عام. ```js export default { @@ -1034,7 +1005,7 @@ export default { }; ``` -Which will result in the following bundle: +مما سيؤدي إلى ما يلي bundle: ```js globalThis.clientContainer.define(/* define args */); // or 'amd-require' window['clientContainer'].require(/*require args*/); @@ -1053,9 +1024,9 @@ export default { }; ``` -Specify a name for the library. +حدد اسمًا لـ library. -- Type: +- النوع: ```ts string | string[] | {amd?: string, commonjs?: string, root?: string | string[]} @@ -1063,19 +1034,19 @@ Specify a name for the library. ### output.library.type -Configure how the library will be exposed. +قم بتخصيص كيفية عرض library. -- Type: `string` +- النوع: `string` - Types included by default are `'var'`, `'module'`, `'modern-module'`, `'assign'`, `'assign-properties'`, `'this'`, `'window'`, `'self'`, `'global'`, `'commonjs'`, `'commonjs2'`, `'commonjs-module'`, `'commonjs-static'`, `'amd'`, `'amd-require'`, `'umd'`, `'umd2'`, `'jsonp'` and `'system'`, but others might be added by plugins. +الأنواع المضمنة افتراضيًا هي `'var'`، `'module'`، `'modern-module'`، `'assign'`، `'assign-properties'`، `'this'`، `'window'`، `'self'`، `'global'`، `'commonjs'`، `'commonjs2'`، `'commonjs-module'`، `'commonjs-static'`، `'amd'`، `'amd-require'`، `'umd'`، `'umd2'`، `'jsonp'` و`'system'`، ولكن يمكن إضافة أشياء أخرى بواسطة plugins. -For the following examples, we'll use `_entry_return_` to indicate the values returned by the entry point. +بالنسبة للأمثلة التالية، سنستخدم `_entry_return_` للإشارة إلى القيم التي يتم إرجاعها بواسطة entry point. -#### Expose a Variable +#### فضح متغير -These options assign the return value of the entry point (e.g. whatever the entry point exported) to the name provided by [`output.library.name`](#outputlibraryname) at whatever scope the bundle was included at. +تقوم هذه الخيارات بتعيين القيمة المرجعة لـ entry point (على سبيل المثال، مهما كان entry point الذي تم تصديره) إلى الاسم المقدم بواسطة [`output.library.name`](#outputlibraryname) في أي نطاق تم تضمين bundle فيه. -##### type: 'var' +##### النوع: "فار" ```js export default { @@ -1089,16 +1060,16 @@ export default { }; ``` -When your library is loaded, the **return value of your entry point** will be assigned to a variable: +عندما يتم تحميل library، سيتم تعيين **قيمة الإرجاع الخاصة بـ entry point** إلى متغير: ```js const MyLibrary = _entry_return_; -// In a separate script with `MyLibrary` loaded… +// في برنامج نصي منفصل مع تحميل `MyLibrary`... MyLibrary.doSomething(); ``` -##### type: 'assign' +##### النوع: "تعيين" ```js export default { @@ -1112,15 +1083,15 @@ export default { }; ``` -This will generate an implied global which has the potential to reassign an existing value (use with caution): +سيؤدي هذا إلى إنشاء عمومية ضمنية لديها القدرة على إعادة تعيين قيمة موجودة (استخدمها بحذر): ```js MyLibrary = _entry_return_; ``` -Be aware that if `MyLibrary` isn't defined earlier your library will be set in global scope. +انتبه إلى أنه إذا لم يتم تعريف `MyLibrary` مسبقًا، فسيتم تعيين library في النطاق العام. -##### type: 'assign-properties' +##### النوع: 'assign-properties' @@ -1136,29 +1107,29 @@ export default { }; ``` -Similar to [`type: 'assign'`](#type-assign) but a safer option as it will reuse `MyLibrary` if it already exists: +يشبه [`type: 'assign'`](#type-assign) ولكنه خيار أكثر أمانًا لأنه سيعيد استخدام `MyLibrary` إذا كان موجودًا بالفعل: ```js -// only create MyLibrary if it doesn't exist +// قم بإنشاء MyLibrary فقط إذا لم يكن موجودًا MyLibrary = typeof MyLibrary === "undefined" ? {} : MyLibrary; -// then copy the return value to MyLibrary -// similarly to what Object.assign does +// ثم انسخ القيمة المرجعة إلى MyLibrary +// بشكل مشابه لما يفعله Object.assistant -// for instance, you export a `hello` function in your entry as follow +// على سبيل المثال، يمكنك تصدير `hello` function في entry الخاص بك على النحو التالي export function hello(name) { console.log(`Hello ${name}`); } -// In another script with MyLibrary loaded -// you can run `hello` function like so +// في برنامج نصي آخر مع MyLibrary تحميلها +// يمكنك تشغيل `hello` function بهذه الطريقة MyLibrary.hello("World"); ``` -#### Expose Via Object Assignment +#### فضح عبر Object المهمة -These options assign the return value of the entry point (e.g. whatever the entry point exported) to a specific object under the name defined by [`output.library.name`](#outputlibraryname). +تقوم هذه الخيارات بتعيين القيمة المرجعة لـ entry point (على سبيل المثال، مهما كان entry point الذي تم تصديره) إلى object محدد تحت الاسم المحدد بواسطة [`output.library.name`](#outputlibraryname). -##### type: 'this' +##### اكتب: "هذا" ```js export default { @@ -1172,17 +1143,17 @@ export default { }; ``` -The **return value of your entry point** will be assigned to `this` under the property named by `output.library.name`. The meaning of `this` is up to you: +سيتم تعيين **قيمة الإرجاع الخاصة بـ entry point** إلى `this` ضمن الخاصية المسماة بواسطة `output.library.name`. معنى `this` متروك لك: ```js this.MyLibrary = _entry_return_; -// In a separate script... +// في نص منفصل... this.MyLibrary.doSomething(); MyLibrary.doSomething(); // if `this` is window ``` -##### type: 'window' +##### النوع: "نافذة" ```js export default { @@ -1196,7 +1167,7 @@ export default { }; ``` -The **return value of your entry point** will be assigned to the `window` object using the `output.library.name` value. +سيتم تعيين **قيمة الإرجاع الخاصة بـ entry point** إلى `window` object باستخدام القيمة `output.library.name`. ```js globalThis.MyLibrary = _entry_return_; @@ -1204,7 +1175,7 @@ globalThis.MyLibrary = _entry_return_; globalThis.MyLibrary.doSomething(); ``` -##### type: 'global' +##### النوع: "عالمي" ```js export default { @@ -1218,7 +1189,7 @@ export default { }; ``` -The **return value of your entry point** will be assigned to the global object using the `output.library.name` value. Depending on the [`target`](/configuration/target/) value, the global object could change respectively, e.g., `self`, `global` or `globalThis`. +سيتم تعيين **قيمة الإرجاع الخاصة بـ entry point** إلى object العامة باستخدام القيمة `output.library.name`. اعتمادًا على قيمة [`target`](/configuration/target/)، يمكن أن تتغير القيمة العامة object على التوالي، على سبيل المثال، `self` أو `global` أو `globalThis`. ```js globalThis.MyLibrary = _entry_return_; @@ -1226,7 +1197,7 @@ globalThis.MyLibrary = _entry_return_; globalThis.MyLibrary.doSomething(); ``` -##### type: 'commonjs' +##### النوع: "كومونجس" ```js export default { @@ -1240,7 +1211,7 @@ export default { }; ``` -The **return value of your entry point** will be assigned to the `exports` object using the `output.library.name` value. As the name implies, this is used in CommonJS environments. +سيتم تعيين **قيمة الإرجاع الخاصة بـ entry point** إلى `exports` object باستخدام القيمة `output.library.name`. كما يوحي الاسم، يتم استخدام هذا في بيئات CommonJS. ```js exports.MyLibrary = _entry_return_; @@ -1248,13 +1219,13 @@ exports.MyLibrary = _entry_return_; require("MyLibrary").doSomething(); ``` -W> Note that not setting a `output.library.name` will cause all properties returned by the entry point to be assigned to the given object; there are no checks against existing property names. +W> لاحظ أن عدم تعيين `output.library.name` سيؤدي إلى تعيين جميع الخصائص التي يتم إرجاعها بواسطة entry point إلى object المحدد؛ لا توجد عمليات فحص ضد أسماء الممتلكات الموجودة. -#### Module Definition Systems +#### Module أنظمة التعريف -These options will result in a bundle that comes with a complete header to ensure compatibility with various module systems. The `output.library.name` option will take on a different meaning under the following `output.library.type` options. +ستؤدي هذه الخيارات إلى bundle الذي يأتي مع رأس كامل لضمان التوافق مع أنظمة module المختلفة. سيأخذ خيار `output.library.name` معنى مختلفًا ضمن خيارات `output.library.type` التالية. -##### type: 'module' +##### النوع: 'module' ```js export default { @@ -1264,18 +1235,18 @@ export default { }, output: { library: { - // do not specify a `name` here + // لا تحدد `name` هنا type: "module", }, }, }; ``` -Output ES Module. +Output كـ ES module. -However this feature is still experimental and not fully supported yet, so make sure to enable [experiments.outputModule](/configuration/experiments/) beforehand. In addition, you can track the development progress in [this thread](https://github.com/webpack/webpack/issues/2933#issuecomment-774253975). +ومع ذلك، لا تزال هذه الميزة تجريبية وغير مدعومة بشكل كامل حتى الآن، لذا تأكد من تمكين [experiments.outputModule](/configuration/experiments/) مسبقًا. بالإضافة إلى ذلك، يمكنك تتبع تقدم التطوير في [هذا الموضوع](https://github.com/webpack/webpack/issues/2933#issuecomment-774253975). -##### type: 'modern-module' +##### النوع: "حديث-module" @@ -1287,32 +1258,32 @@ export default { }, output: { library: { - // do not specify a `name` here + // لا تحدد `name` هنا type: "modern-module", }, }, }; ``` -This configuration generates tree-shakable output for ES Modules. +ينشئ هذا التخصيص output شجرة قابلة للاهتزاز لـ ES Modules. -However this feature is still experimental and not fully supported yet, so make sure to enable [experiments.outputModule](/configuration/experiments/) beforehand. +ومع ذلك، لا تزال هذه الميزة تجريبية وغير مدعومة بشكل كامل حتى الآن، لذا تأكد من تمكين [experiments.outputModule](/configuration/experiments/) مسبقًا. -##### type: 'commonjs2' +##### النوع: "commonjs2" ```js export default { // … output: { library: { - // note there's no `name` here + // لاحظ أنه لا يوجد `name` هنا type: "commonjs2", }, }, }; ``` -The **return value of your entry point** will be assigned to the `module.exports`. As the name implies, this is used in Node.js (CommonJS) environments: +سيتم تعيين **قيمة الإرجاع الخاصة بـ entry point** إلى `module.exports`. كما يوحي الاسم، يُستخدم هذا في بيئات Node.js (CommonJS): ```js export default _entry_return_; @@ -1320,15 +1291,15 @@ export default _entry_return_; require("MyLibrary").doSomething(); ``` -If we specify `output.library.name` with `type: commonjs2`, the return value of your entry point will be assigned to the `module.exports.[output.library.name]`. +إذا قمنا بتحديد `output.library.name` مع `type: commonjs2`، فسيتم تعيين القيمة المرجعة لـ entry point إلى `module.exports.[output.library.name]`. -T> Wondering the difference between CommonJS and CommonJS2 is? While they are similar, there are some subtle differences between them that are not usually relevant in the context of webpack. (For further details, please [read this issue](https://github.com/webpack/webpack/issues/1114).) +T> هل تتساءل عن الفرق بين CommonJS وCommonJS2؟ على الرغم من أنها متشابهة، إلا أن هناك بعض الاختلافات الدقيقة بينهما والتي لا تكون ذات صلة عادةً بسياق webpack. (لمزيد من التفاصيل، يرجى [قراءة هذا العدد](https://github.com/webpack/webpack/issues/1114).) -##### type: 'commonjs-module' +##### النوع: "commonjs-module" -`commonjs-module` is equivalent to [`commonjs2`](#type-commonjs2). We may remove `commonjs-module` in future versions. +`commonjs-module` يعادل [`commonjs2`](#type-commonjs2). قد نقوم بإزالة `commonjs-module` في الإصدارات المستقبلية. -##### type: 'commonjs-static' +##### النوع: "commonjs-static" @@ -1337,16 +1308,16 @@ export default { // … output: { library: { - // note there's no `name` here + // لاحظ أنه لا يوجد `name` هنا type: "commonjs-static", }, }, }; ``` -Individual exports will be set as properties on `module.exports`. The "static" in the name refers to the output being statically analysable, and thus named exports are importable into ESM via Node.js: +سيتم تعيين الصادرات الفردية كخصائص على `module.exports`. تشير كلمة "ثابت" في الاسم إلى أن output قابل للتحليل بشكل ثابت، وبالتالي فإن الصادرات المسماة قابلة للاستيراد إلى ESM عبر Node.js: -Input: +الإدخال: ```js export function doSomething() {} @@ -1362,27 +1333,27 @@ function doSomething() {} exports.doSomething = __webpack_exports__.doSomething; ``` -Consumption (CommonJS): +الاستهلاك (CommonJS): ```js const { doSomething } = require("./output.cjs"); // doSomething => [Function: doSomething] ``` -Consumption (ESM): +الاستهلاك (ESM): ```js import { doSomething } from "./output.cjs"; // doSomething => [Function: doSomething] ``` -T> This is useful when source code is written in ESM and the output should be compatible with both CJS and ESM. For further details, please [read this issue](https://github.com/webpack/webpack/issues/14998) or [this article](https://dev.to/jakobjingleheimer/configuring-commonjs-es-modules-for-nodejs-12ed) (specifically, [this section](https://dev.to/jakobjingleheimer/configuring-commonjs-es-modules-for-nodejs-12ed#publish-only-a-cjs-distribution-with-property-exports)). +T> يكون هذا مفيدًا عند كتابة كود المصدر باللغة ESM ويجب أن يكون output متوافقًا مع كل من CJS وESM. لمزيد من التفاصيل، يرجى [قراءة هذه المشكلة](https://github.com/webpack/webpack/issues/14998) أو [هذه المقالة](https://dev.to/jakobjingleheimer/configuring-commonjs-es-modules-for-nodejs-12ed) (على وجه التحديد، [هذا القسم](https://dev.to/jakobjingleheimer/configuring-commonjs-es-modules-for-nodejs-12ed#publish-only-a-cjs-distribution-with-property-exports)). -##### type: 'amd' +##### النوع: "أيه إم دي" -This will expose your library as an AMD module. +سيؤدي هذا إلى كشف library باعتباره AMD module. -AMD modules require that the entry chunk (e.g. the first script loaded by the ` + -``` +```` **webpack.config.js** @@ -62,9 +51,9 @@ Let's make a minor change to our project before we get started: }; ``` -## Loading CSS +## تحميل ملفات CSS -In order to `import` a CSS file from within a JavaScript module, you need to install and add the [style-loader](/loaders/style-loader) and [css-loader](/loaders/css-loader) to your [`module` configuration](/configuration/module): +لكي تتمكن من `import` ملف CSS من داخل وحدة JavaScript، تحتاج إلى تثبيت وإضافة [style-loader](/loaders/style-loader) و [css-loader](/loaders/css-loader) إلى إعدادات [`module`](/configuration/module): ```bash npm install --save-dev style-loader css-loader @@ -96,9 +85,9 @@ npm install --save-dev style-loader css-loader }; ``` -Module loaders can be chained. Each loader in the chain applies transformations to the processed resource. A chain is executed in reverse order (right to left). +يمكن ربط الـ loaders معًا في سلسلة. كل loader يقوم بتطبيق تحويلات على الملف الذي تتم معالجته. ويتم تنفيذ السلسلة بالعكس (من اليمين إلى اليسار). -For example, given the following rule: +على سبيل المثال: ```js export default { @@ -113,9 +102,9 @@ export default { }; ``` -Even though `postcss-loader` appears before `sass-loader` in the `use` array, webpack runs `sass-loader` first (compiling Sass into CSS), then runs `postcss-loader` on the result. +بالرغم من أن `postcss-loader` يظهر قبل `sass-loader` داخل المصفوفة `use`، إلا أن webpack يقوم أولًا بتشغيل `sass-loader` (لتحويل Sass إلى CSS)، ثم يمرر النتيجة إلى `postcss-loader`. -If this order is not maintained, webpack may throw errors. +إذا لم يتم الحفاظ على هذا الترتيب، فقد يقوم webpack بإظهار أخطاء. **project** @@ -160,34 +149,23 @@ If this order is not maintained, webpack may throw errors. document.body.appendChild(component()); ``` -Now run your build command: +الآن قم بتشغيل أمر البناء: ```bash $ npm run build - -... -[webpack-cli] Compilation finished -asset bundle.js 72.6 KiB [emitted] [minimized] (name: main) 1 related asset -runtime modules 1000 bytes 5 modules -orphan modules 326 bytes [orphan] 1 module -cacheable modules 539 KiB - modules by path ./node_modules/ 538 KiB - ./node_modules/lodash/lodash.js 530 KiB [built] [code generated] - ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js 6.67 KiB [built] [code generated] - ./node_modules/css-loader/dist/runtime/api.js 1.57 KiB [built] [code generated] - modules by path ./src/ 965 bytes - ./src/index.js + 1 modules 639 bytes [built] [code generated] - ./node_modules/css-loader/dist/cjs.js!./src/style.css 326 bytes [built] [code generated] -webpack 5.x.x compiled successfully in 2231 ms ``` -Open up `dist/index.html` in your browser again and you should see that `Hello webpack` is now styled in red. To see what webpack did, inspect the page (don't view the page source, as it won't show you the result, because the `