Webpack Interview Questions Hindi mein

Webpack: Module Bundling और Build Optimization कोर्स के 31 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

मॉड्यूल 1: शुरुआत

1. Bundling का प्राथमिक उद्देश्य क्या है?

  1. Code को समझना मुश्किल बनाना।
  2. HTTP requests को reduce करना और load time improve करना।
  3. Modules में extra features जोड़ना।
  4. JavaScript को किसी दूसरी language से बदलना।
जवाब देखें

जवाब: HTTP requests को reduce करना और load time improve करना।

Bundling कई modules को कम files में combine करके network overhead को reduce करता है और application load को तेज करता है।

पाठ: Bundling का परिचय

2. [contenthash] output filename में क्या करता है?

  1. File को automatically compress करता है।
  2. Bundle में metadata जोड़ता है।
  3. यह तय करना कि file को कौन-सा loader process करेगा।
  4. File content के आधार पर unique hash generate करता है।
जवाब देखें

जवाब: File content के आधार पर unique hash generate करता है।

Content hash filename को बदलकर cache busting ensure करता है जब content बदलता है।

पाठ: Core concepts: entry और output

मॉड्यूल 2: बुनियाद

3. 'use' array में loaders किस direction में execute होते हैं?

  1. Right से left
  2. Left से right
  3. Random order
  4. Alphabetical order
जवाब देखें

जवाब: Right से left

Loaders right से left execute होते हैं, तो rightmost loader पहले चलता है।

पाठ: Loaders और rules

4. Loaders और plugins के बीच मुख्य अंतर क्या है?

  1. Plugins files को process करते हैं; loaders lifecycle को extend करते हैं।
  2. Loaders specific files को transform करते हैं; plugins build lifecycle में hook करते हैं।
  3. वे अलग तरीके से एक ही चीज करते हैं।
  4. Plugins केवल build खत्म होने के बाद चलते हैं।
जवाब देखें

जवाब: Loaders specific files को transform करते हैं; plugins build lifecycle में hook करते हैं।

Loaders individual files पर काम करते हैं, जबकि plugins Webpack compilation process में hook करते हैं।

पाठ: Plugins और extensions

5. Production mode का उपयोग कब करना चाहिए?

  1. Development के दौरान fast rebuilds के लिए।
  2. Better debugging को enable करने के लिए।
  3. Final deployments के लिए bundle size को minimize करने के लिए।
  4. केवल unit tests चलाते समय।
जवाब देखें

जवाब: Final deployments के लिए bundle size को minimize करने के लिए।

Production mode size और performance के लिए optimize करता है। Development mode rebuild speed को prioritize करता है।

पाठ: Configuration और modes

मॉड्यूल 3: Core mechanics

6. Module resolution क्या करता है?

  1. Module code में errors को fix करता है।
  2. Modules को different formats में convert करता है।
  3. Modules को npm registry पर upload करना।
  4. Webpack के algorithm के अनुसार modules को find और load करता है।
जवाब देखें

जवाब: Webpack के algorithm के अनुसार modules को find और load करता है।

Resolution module file को find करने की process है जब आप इसे import करते हैं।

पाठ: Module resolution

7. Tree-shaking क्या है?

  1. Bugs find करने के लिए dependency tree को shake करना।
  2. Bundle से unused code को remove करना।
  3. Files में imports को reorder करना।
  4. Files के नाम छोटे करना।
जवाब देखें

जवाब: Bundle से unused code को remove करना।

Tree-shaking production builds में unused exports को eliminate करके bundle size को reduce करता है।

पाठ: Tree-shaking और code splitting

मॉड्यूल 4: Assets को transform करना

8. CSS को extract करने का advantage क्या है?

  1. CSS file size को reduce करता है।
  2. CSS को use होने से prevent करता है।
  3. Caching और parallel downloads को enable करता है।
  4. CSS-in-JS की जरूरत खत्म करना।
जवाब देखें

जवाब: Caching और parallel downloads को enable करता है।

Extracted CSS files को separately cache किया जा सकता है और JavaScript के साथ parallel में download किया जा सकता है।

पाठ: CSS और styling

9. Images को कब inline करना चाहिए?

  1. सभी images को हमेशा inline करना चाहिए।
  2. Compression के लिए बड़ी images को inline करना चाहिए।
  3. कभी नहीं, क्योंकि inlining build तोड़ देता है।
  4. जब files छोटी हों, ताकि अतिरिक्त HTTP requests बच सकें।
जवाब देखें

जवाब: जब files छोटी हों, ताकि अतिरिक्त HTTP requests बच सकें।

छोटी files को base64 में inline करने से HTTP requests बचती हैं। बड़ी files को बेहतर caching के लिए अलग रखा जाता है।

पाठ: Images और assets

मॉड्यूल 5: Development workflow

10. HMR क्या करता है?

  1. Full page reload के बिना modules को replace करता है।
  2. Bundles को automatically compress करता है।
  3. JavaScript code को minify करता है।
  4. हर बदलाव पर Node.js process restart करना।
जवाब देखें

जवाब: Full page reload के बिना modules को replace करता है।

HMR running application में modules को update करता है बिना full page reload के, state को preserve करता है।

पाठ: Dev server और hot reload

11. Source maps क्या provide करते हैं?

  1. JavaScript files का compression।
  2. Bundled code से original sources में mapping।
  3. Code के लिए security protection।
  4. Runtime पर bugs अपने-आप ठीक करना।
जवाब देखें

जवाब: Bundled code से original sources में mapping।

Source maps minified/bundled code को original source files में map करके debugging को enable करते हैं।

पाठ: Debugging और source maps

मॉड्यूल 6: Practical usage

12. Node.js library के लिए कौन सा target use करना चाहिए?

  1. 'web' browser compatibility के लिए।
  2. 'electron' cross-platform के लिए।
  3. 'node' Node built-ins को enable करने के लिए।
  4. Node built-ins से बचने के लिए 'webworker'।
जवाब देखें

जवाब: 'node' Node built-ins को enable करने के लिए।

'node' target Node.js built-ins को ensure करता है कि available हों और bundled न हों।

पाठ: विभिन्न targets के लिए build करना

13. Framework CLIs का उपयोग करने का benefit क्या है?

  1. तेजी से runtime performance।
  2. Guaranteed छोटे bundle sizes।
  3. इनसे Node.js की जरूरत खत्म हो जाती है।
  4. Framework की जरूरतों के लिए pre-configured Webpack।
जवाब देखें

जवाब: Framework की जरूरतों के लिए pre-configured Webpack।

Framework CLIs pre-configured Webpack setups provide करते हैं जो framework के लिए optimized हों।

पाठ: Frameworks के साथ काम करना

मॉड्यूल 7: Optimization

14. Minification क्या है?

  1. Functionality को preserve करते हुए unnecessary characters को remove करना।
  2. Code को समझना मुश्किल बनाना।
  3. Bundles को smaller pieces में split करना।
  4. सुरक्षा के लिए bundle को encrypt करना।
जवाब देखें

जवाब: Functionality को preserve करते हुए unnecessary characters को remove करना।

Minification whitespace, comments को remove करके और variable names को shorten करके file size को reduce करता है।

पाठ: Minification और compression

15. Vendor code को अलग क्यों करें?

  1. Vendor code को separate file में होना जरूरी है।
  2. Vendors rarely बदलते हैं, longer cache हो सकता है।
  3. यह bundles को size में छोटा बनाता है।
  4. Webpack के लिए vendor files का अलग होना जरूरी है।
जवाब देखें

जवाब: Vendors rarely बदलते हैं, longer cache हो सकता है।

Vendor code infrequently बदलता है, तो separating करने से browsers इसे cache कर सकते हैं जबकि application code बार-बार update होता है।

पाठ: Caching strategies

मॉड्यूल 8: Advanced patterns

16. Loader को input के रूप में क्या मिलता है?

  1. केवल file path।
  2. Compiled JavaScript output।
  3. File की source code content।
  4. Browser का DOM tree।
जवाब देखें

जवाब: File की source code content।

Loaders file content को string के रूप में receive करते हैं और transformed content return करते हैं।

पाठ: Custom loaders और plugins

17. Monorepos के लिए resolve.modules को क्यों configure करें?

  1. Bundling process को तेज करने के लिए।
  2. Shared dependencies को compress करने के लिए।
  3. Symlinks को पूरी तरह disable करने के लिए।
  4. Node_modules के अलावा workspace locations में packages को find करने के लिए।
जवाब देखें

जवाब: Node_modules के अलावा workspace locations में packages को find करने के लिए।

resolve.modules Webpack को बताता है कि packages को कहाँ search करना है, local workspace packages के resolution को enable करता है।

पाठ: Monorepos और workspaces

मॉड्यूल 9: Integration

18. fork-ts-checker-webpack-plugin क्या करता है?

  1. Faster builds के लिए parallel में type checking चलाता है।
  2. Bundle से TypeScript को remove करता है।
  3. TypeScript में decorators को enable करता है।
  4. TypeScript को Python में बदलता है।
जवाब देखें

जवाब: Faster builds के लिए parallel में type checking चलाता है।

fork-ts-checker-webpack-plugin type checking को अलग process में transfer करता है, faster compilation को allow करता है।

पाठ: TypeScript और transpilation

19. CI में bundles को क्यों analyze करें?

  1. Builds को तेज बनाने के लिए।
  2. Performance regressions को early catch करने के लिए।
  3. Deployment time को reduce करने के लिए।
  4. Lint errors अपने-आप ठीक करने के लिए।
जवाब देखें

जवाब: Performance regressions को early catch करने के लिए।

CI में bundle analysis production तक पहुँचने से पहले size increases को detect करता है।

पाठ: Testing और CI/CD integration

मॉड्यूल 10: पुनरावलोकन

20. एक common Webpack pitfall क्या है?

  1. बहुत सारे loaders का उपयोग करना।
  2. Minification हमेशा खराब है।
  3. Wrong loader order transformation failures cause करता है।
  4. CI में builds चलाना।
जवाब देखें

जवाब: Wrong loader order transformation failures cause करता है।

Loader order critical है क्योंकि वे right-to-left execute होते हैं, और incorrect order transformation pipeline को break करता है।

पाठ: Common pitfalls और solutions

21. Build performance को कैसे measure करें?

  1. Bundle में files की संख्या count करें।
  2. Build के दौरान console logs check करें।
  3. साथियों से पूछना कि build कितना लंबा लगता है।
  4. --profile flag या speed-measure-webpack-plugin का उपयोग करें।
जवाब देखें

जवाब: --profile flag या speed-measure-webpack-plugin का उपयोग करें।

--profile flag और speed-measure-webpack-plugin प्रत्येक build step के लिए detailed timing information provide करते हैं।

पाठ: Performance monitoring और profiling

22. आपको Webpack के बजाय Vite का उपयोग कब करना चाहिए?

  1. Fast dev experience के साथ simpler projects के लिए।
  2. जब आपको maximum customization की जरूरत हो।
  3. केवल production builds के लिए।
  4. जब आपको Internet Explorer 6 support करना हो।
जवाब देखें

जवाब: Fast dev experience के साथ simpler projects के लिए।

Vite native ESM के साथ fast development experience में excel करता है। Webpack extensive customization की जरूरत वाले projects के लिए बेहतर है।

पाठ: Alternative bundlers और migration

23. एक configuration को production-ready क्या बनाता है?

  1. सबसे बड़े bundle size का उपयोग करना।
  2. Minification, sourcemaps, caching, code splitting।
  3. सभी optimizations को disable करना।
  4. Hard-coded absolute paths और बिना hashing।
जवाब देखें

जवाब: Minification, sourcemaps, caching, code splitting।

Production-ready configs minification, code splitting, sourcemaps के through performance, caching को optimize करते हैं।

पाठ: Real-world applications और best practices

24. Dependency graph बनाना Webpack कहाँ से शुरू करे, यह कौन-सा option बताता है?

  1. output
  2. entry
  3. resolve
  4. devtool
जवाब देखें

जवाब: entry

Entry point वह root है जहाँ से Webpack imports को follow करता है।

पाठ: Real-world applications और best practices

25. Rule के use array में CSS को सही तरह process करने वाला loader order कौन-सा है?

  1. ['css-loader', 'style-loader']
  2. ['style-loader', 'css-loader']
  3. ['css-loader'] only
  4. ['babel-loader', 'style-loader']
जवाब देखें

जवाब: ['style-loader', 'css-loader']

Loaders right-to-left चलते हैं, इसलिए css-loader पहले parse करता है और style-loader result inject करता है।

पाठ: Real-world applications और best practices

26. Loader और plugin में मुख्य अंतर क्या है?

  1. Loaders hook into the whole build lifecycle; plugins transform single files.
  2. Loaders transform individual files; plugins hook into the build lifecycle.
  3. Plugins run only in development.
  4. There is no difference.
जवाब देखें

जवाब: Loaders transform individual files; plugins hook into the build lifecycle.

Loaders file type के अनुसार काम करते हैं; plugins बड़े build tasks संभालते हैं।

पाठ: Real-world applications और best practices

27. Production bundle से unused exports कौन-सी technique हटाती है?

  1. Tree-shaking
  2. Hot module replacement
  3. Source mapping
  4. Aliasing
जवाब देखें

जवाब: Tree-shaking

Tree-shaking static ES module imports के आधार पर dead code हटाती है।

पाठ: Real-world applications और best practices

28. भारी module को केवल तब कैसे load करें जब user को उसकी जरूरत हो?

  1. Use a dynamic import()
  2. Use a static import at the top
  3. Set mode to development
  4. Rename the entry file
जवाब देखें

जवाब: Use a dynamic import()

Dynamic import() अलग chunk बनाता है जो जरूरत पड़ने पर load होता है।

पाठ: Real-world applications और best practices

29. Output filenames में [contenthash] क्यों उपयोग करें?

  1. It encrypts the bundle.
  2. It changes only when content changes, enabling long-term caching.
  3. It speeds up the dev server.
  4. It enables source maps.
जवाब देखें

जवाब: It changes only when content changes, enabling long-term caching.

Unchanged file का नाम वही रहता है, इसलिए browsers cached copy reuse करते हैं।

पाठ: Real-world applications और best practices

30. webpack-dev-server में HMR क्या करता है?

  1. Minifies code on save.
  2. Replaces changed modules without a full page reload.
  3. Uploads source maps to production.
  4. Splits vendor chunks.
जवाब देखें

जवाब: Replaces changed modules without a full page reload.

HMR बदले हुए modules को उसी जगह बदलता है और application state बनाए रखता है।

पाठ: Real-world applications और best practices

31. Bundle बड़ा होने का कारण खोजने में कौन-सा tool मदद करता है?

  1. webpack-bundle-analyzer
  2. html-webpack-plugin
  3. css-loader
  4. fork-ts-checker-webpack-plugin
जवाब देखें

जवाब: webpack-bundle-analyzer

Analyzer bundle की composition दिखाता है, जिससे बड़ी dependencies आसानी से दिखती हैं।

पाठ: Real-world applications और best practices

← कोर्स पर वापस जाएँ