{"library":"monosize-bundler-rspack","title":"monosize Rspack Bundler Plugin","description":"monosize-bundler-rspack is a specialized plugin for the `monosize` tool, designed to integrate Rspack as the underlying bundler for comprehensive JavaScript bundle size analysis. It allows developers to harness the high performance of Rspack for evaluating bundle sizes within large-scale monorepos or projects optimized for `monosize`. Currently at version 0.2.1, it is an actively developed component within the broader Microsoft `monosize` ecosystem. While exact release cadences are not strictly defined for this plugin, its early version number indicates ongoing development and potential for rapid evolution. A key differentiator is its default 'batch build mode,' which significantly enhances build speed (8-14x faster in typical scenarios) compared to sequential bundling, making it exceptionally well-suited for efficient monorepo size optimization. The plugin also provides an API to customize the underlying rsbuild configuration, offering flexibility for intricate build requirements.","language":"javascript","status":"active","last_verified":"Thu Apr 23","install":{"commands":["npm install monosize-bundler-rspack"],"cli":{"name":"monosize","version":null}},"imports":["import rspackBundler from 'monosize-bundler-rspack';","import type { RspackBundlerConfig } from 'monosize-bundler-rspack';","import type { CustomizeConfigCallback } from 'monosize-bundler-rspack';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"/* monosize.config.mjs */\nimport rspackBundler from 'monosize-bundler-rspack';\n\n/**\n * @type {import('monosize').MonosizeConfig}\n */\nexport default {\n  // Define your workspace roots for monosize to scan\n  workspaces: [\n    'packages/*',\n    'apps/*'\n  ],\n  // Specify fixtures (entry points) for size measurement\n  fixtures: {\n    'my-component': 'packages/my-component/src/index.ts',\n    'my-util': 'packages/my-util/src/index.ts'\n  },\n  // Integrate the Rspack bundler plugin\n  bundler: rspackBundler(config => {\n    // Example: Customize Rspack's resolve alias for specific packages\n    config.resolve ??= {};\n    config.resolve.alias = {\n      ...config.resolve.alias,\n      'some-internal-lib': 'libs/some-internal-lib/dist/esm/index.js'\n    };\n    // Example: Add a new rule for handling SVG files\n    config.module?.rules?.push({\n        test: /\\.svg$/,\n        type: 'asset/resource'\n    });\n    return config;\n  }),\n  // Other monosize configurations...\n  output: {\n    dir: './monosize-results',\n    filename: 'report.json'\n  }\n};\n\n/* Example of how to run this config in your package.json */\n// \"scripts\": {\n//   \"measure-size\": \"monosize measure\"\n// }","lang":"typescript","description":"This quickstart demonstrates configuring `monosize.config.mjs` to use `monosize-bundler-rspack` as the bundler, including examples of customizing the underlying rsbuild configuration for aliases and module rules.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}