{"id":13677298,"url":"https://github.com/kitchenshelf/serverless-rspack","last_synced_at":"2026-01-12T02:22:36.440Z","repository":{"id":239568729,"uuid":"796588438","full_name":"kitchenshelf/serverless-rspack","owner":"kitchenshelf","description":"A Serverless framework  plugin for zero-config JavaScript and TypeScript code bundling using the high performance Rust-based JavaScript bundler rspack","archived":false,"fork":false,"pushed_at":"2025-07-26T16:25:13.000Z","size":1374,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-19T20:56:59.246Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kitchenshelf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-05-06T08:39:26.000Z","updated_at":"2025-08-21T19:59:29.000Z","dependencies_parsed_at":"2024-05-18T10:47:14.407Z","dependency_job_id":"e95f821f-027d-4d0a-893c-e54e71a769f2","html_url":"https://github.com/kitchenshelf/serverless-rspack","commit_stats":null,"previous_names":["kitchenshelf/serverless-rspack"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/kitchenshelf/serverless-rspack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitchenshelf%2Fserverless-rspack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitchenshelf%2Fserverless-rspack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitchenshelf%2Fserverless-rspack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitchenshelf%2Fserverless-rspack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitchenshelf","download_url":"https://codeload.github.com/kitchenshelf/serverless-rspack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitchenshelf%2Fserverless-rspack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28332071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:40.015Z","updated_at":"2026-01-12T02:22:36.428Z","avatar_url":"https://github.com/kitchenshelf.png","language":"TypeScript","funding_links":[],"categories":["Resources"],"sub_categories":["Ecosystem"],"readme":"# ⚡ serverless-rspack\n\n[Serverless Framework](https://www.serverless.com) plugin for zero-config JavaScript and TypeScript code bundling using the high performance Rust-based JavaScript bundler [`rspack`](https://rspack.dev/guide/start/introduction)\n\n[![Serverless][ico-serverless]][link-serverless]\n[![Build Status][ico-build]][link-build]\n[![NPM][ico-npm]][link-npm]\n\nLook for the plugin under the [/libs](/libs/serverless-rspack/) directory.\n\nExample serverless projects are under the [/examples](/examples) directory.\n\nFor Developers - [DEVELOPER.MD](./docs/DEVELOPER.md)\n\n\n## Features\n\n- From zero to hero: configuration possibilities range from zero-config to fully customizable\n- Build and runtime performance at its core\n- Supports `sls package`, `sls deploy`, `sls deploy function`\n- Integrates with [`Serverless Invoke Local`](https://www.serverless.com/framework/docs/providers/aws/cli-reference/invoke-local) \u0026 [`serverless-offline`](https://github.com/dherault/serverless-offline)\n\n## Table of Contents\n\n- [Install](#install)\n  - [Serverless V4](#serverless-v4-requirement)\n- [Plugin Options](#plugin-options)\n  - [Examples](#examples)\n  - [Options](#options)\n    - [Read-only default Rspack Options](#read-only-default-rspack-options)\n- [Supported Runtimes](#supported-runtimes)\n- [Advanced Configuration](#advanced-configuration)\n  - [Config File](#config-file)\n    - [Config File Merge Strategies](#config-file-merge-strategies)\n  - [External Dependencies](#external-dependencies)\n  - [Scripts](#scripts)\n    - [Function Scripts](#function-scripts)\n    - [Global Scripts](#global-scripts)\n  - [Doctor](#doctor)\n- [Integrations](#integrations)\n  - [Serverless Offline](#serverless-offline)\n- [Known Issues](#known-issues)\n\n\n## Install\n\n```sh\n# install `serverless-rspack`\nyarn add --dev @kitchenshelf/serverless-rspack\n# or\nnpm install -D @kitchenshelf/serverless-rspack\n# or\npnpm install -D @kitchenshelf/serverless-rspack\n```\n\nAdd the following plugin to your `serverless.yml`:\n\n```yaml\nplugins:\n  - @kitchenshelf/serverless-rspack\n```\n\n### Serverless v4 requirement\n\nIf you are using Serverless v4 you must disable the default builtin ESBuild support in your `serverless.yml`\n\n```yml\nbuild:\n  esbuild: false\n```\n\n## Plugin Options\n\nBy default, no plugin options is required, but you can override the reasonable defaults via the `custom.rspack` section in the `serverless.yml` file.\n\n```yml\ncustom:\n  rspack:\n    mode: 'production'\n    esm: true\n```\n\n### Examples\n\nSee [example folder](../../examples) for example plugin option configuration.\n\n### Options\n\n| Option                        | Description                                                                                                                            | Default      |\n| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------ |\n| `zipConcurrency`              | The number of concurrent zip operations to run at once. eg. `8`. _NOTE_: This can be memory intensive and could produce slower builds. | `Infinity`   |\n| `keepOutputDirectory`         | Keeps the `.rspack` output folder. Useful for debugging.                                                                               | `false`      |\n| `stats`                       | Generate packaging information that can be used to analyze module dependencies and optimize compilation speed.                         | `false`      |\n| [`config`](#config-file)      | rspack config options.                                                                                                                 | `undefined`  |\n| `config.path`                 | Relative rspack config path.                                                                                                           | `undefined`  |\n| [`config.strategy`](#config-file-merge-strategies) | Strategy to use when a rspack config is provided.                                                                 | `override`   |\n| `esm`                         | Output format will be ESM (experimental).                                                                                              | `false`      |\n| `mode`                        | Used to set the build mode of Rspack to enable the default optimization strategy (https://www.rspack.dev/config/mode).                 | `production` |\n| `tsConfig`                    | Relative path to your tsconfig.                                                                                                        | `undefined`  |\n| `sourcemap`                   | Configure rspack [sourcemaps](https://rspack.dev/config/devtool).                                                                      | `false`      |\n| [`externals`](#external-dependencies) | Provides a way of excluding dependencies from the output bundles.                                                              | `undefined`  |\n| [`scripts`](#scripts)         | Array of scripts to execute after your code has been bundled by rspack.                                                                | `undefined`  |\n| [`doctor`](#doctor)           | Enable the `Rsdoctor` plugin.                                                                                                          | `undefined`  |\n\n#### Read-only default Rspack Options\n\nThe following `rspack` options are automatically set and **cannot** be overwritten.\n\n| Option        | Notes                                                                                                            |\n| ------------- | ---------------------------------------------------------------------------------------------------------------- |\n| `entry`       | Handler entries are determined by the plugin                                                                     |\n| `output.path` | The plugin needs to have full control over where bundles are output to, so it can correctly create zip artifacts |\n\n#### Function Options\n\n| Option   | Description                                                                                   | Default     |\n| -------- | --------------------------------------------------------------------------------------------- | ----------- |\n| `rspack` | Set this property on a function definition to force the handler to be processed by the plugin | `undefined` |\n\n\n## Supported Runtimes\n\nThis plugin will automatically process any function that has a runtime that starts with `node` i.e `nodejs20.x`\n\n### Non-Node functions\n\nIf you wish to use this plugin alongside non Node functions like Python or functions with images, this plugin will automatically ignore any function which does not match the supported runtimes.\n\nIf you wish to force a function to be process set `rspack: true` on a function definition. This is handy when using custom provided node runtimes i.e `  runtime: 'provided.al2023'`\n\n⚠️ **Note: this will only work if your custom runtime and function are written in JavaScript/Typescript.\nMake sure you know what you are doing when this option is set to `true`**\n\n\n## Advanced Configuration\n\n### Config file\n\nRspack configuration can be defined by a config file.\n\n```yml\ncustom:\n  rspack:\n    config:\n      path: './rspack.config.js'\n```\n\n```js\n// rspack.config.js\nmodule.exports = (serverless) =\u003e {\n  externals: ['lodash'],\n  // etc\n};\n```\n\nYou can also return an async function.\n\n```js\nmodule.exports = async (serverless) =\u003e {\n  const getExternals = new Promise((resolve, reject) =\u003e {\n    setTimeout(() =\u003e {\n      resolve(['lodash']);\n    }, 250);\n  });\n\n  const externals = await getExternals;\n  \n  return {\n    externals: externals,\n    // etc\n  };\n};\n```\n\n#### Config file merge strategies\n\nYou can change how the plugin uses a provided config via the `strategy` option:\n\n```yml\ncustom:\n  rspack:\n    config:\n      path: './rspack.config.js'\n      strategy: combine\n```\n\n1. `override`: ***Default*** - Enables power users to provided their own complete Rspack configuration: `rspack.config.js` -\u003e [`PluginReadOnlyDefaults`](#read-only-default-rspack-options)\n2. `combine`: Enables providing partial configuration.  Merges all configuration together: `PluginDefaults` -\u003e `PluginOptions` -\u003e `rspack.config.js` -\u003e [`PluginReadOnlyDefaults`](#read-only-default-rspack-options).\n\n⚠️ **Note: Pay attention to the order in which configuration is combined. Each time the right take precedence. **\n\n### External Dependencies\n\nBy providing a regex you can mark packages as `external` and they will be excluded from the output bundles.\n\n```yml\ncustom:\n  rspack:\n    externals:\n      - \"^@aws-sdk\\/.*$\"\n      - \"^@smithy\\/.*$\"\n      - '^isin-validator$'\n```\n\n### Scripts\n\nRun custom shell commands after your code has been bundled by rspack. This is useful for modifying the output of the build before it is packaged.\n\nThere are two types of scripts:\n\n1. **Function**: Executed once per defining function after the bundle step.\n2. **Global**: Executed once before the package step.\n\n**Order**: `bundle` -\u003e `function scripts` -\u003e `global scripts` -\u003e `package`\n\n⚠️ **Note: Scripts run sequentially and will fail the build if any errors occur in any of the scripts.**\n\nThe following environment variables are available to all your scripts:\n\n- `process.env`: All system environment variables.\n- `KS_SERVICE_DIR`: The absolute path to the service directory (e.g. `/Users/user/code/my-service`).\n- `KS_BUILD_OUTPUT_FOLDER`: The name of the build output folder (e.g. `.rspack`).\n- `KS_PACKAGE_OUTPUT_FOLDER`: The name of the package output folder (e.g. `.serverless`).\n\n#### Function Scripts\n\nScripts are executed from the function directory in the output folder i.e `.rspack/\u003cfunction-name\u003e`.\n\n##### Usage\n\n```yml\nfunctions:\n  app3:\n    handler: src/App3.handler\n    runtime: nodejs20.x\n    rspack:\n      enable: true\n      scripts:\n        - 'echo \"First function script\"'\n        - 'npx npm init -y \u0026\u0026 npm install --force --os=linux --cpu=x64 --include=optional sharp @img/sharp-linux-x64'\n        - 'cp $KS_SERVICE_DIR/src/my-image.jpeg ./'\n        - 'echo \"Last function script\"'\n```\n\nThe following extra environment variables are available to your function scripts:\n\n- `KS_FUNCTION_NAME`: The name of the function being processed.\n\n#### Global Scripts\n\nScripts are executed from the root of the service directory.\n\n##### Usage\n\n```yml\ncustom:\n  rspack:\n    externals: ['^@aws-sdk/.*$'],\n    scripts:\n      - 'echo \"First global script\"'\n      - 'echo \"Last global script\"'\n```\n\n### Doctor\n\n[Rsdoctor](https://rsdoctor.dev/guide/start/intro) is a one-stop tool for diagnosing and analyzing the build process and build artifacts.\n\nThe serverless-rspack plugin will automatically enable the `Rsdoctor` plugin when the `doctor` option is provided.\n\n```yml\ncustom:\n  rspack:\n    doctor: true\n```\n\nYou can also provide an `outputDirectory` to specify where the report should be saved. By default, the report will be saved in the `.rspack` folder.\n\n```yml\ncustom:\n  rspack:\n    doctor:\n      enable: true\n      outputDirectory: ./doctor-report\n```\n\n⚠️ **Note: Rsdoctor is configured to run in [`brief`](https://rsdoctor.dev/guide/start/cicd#enabling-brief-mode) mode. If you want to use another mode, you can register `RsdoctorRspackPlugin` manually using the [rspack config option](#config-file).**\n\n## Integrations\n\n### Serverless Offline\n\nThe plugin has first class support for [serverless-offline](https://github.com/dherault/serverless-offline).\n\nAdd the plugins to your `serverless.yml` file and make sure that `serverless-rspack`\nprecedes `serverless-offline` as the order is important:\n\n```yaml\nplugins: ...\n  - serverless-rspack\n  ...\n  - serverless-offline\n  ...\n```\n\nRun `serverless offline start` to start the Lambda/API simulation.\n\n⚠️ **Note: The plugin will automatically set sourcemap to `source-map` when running in offline mode and change the `devtoolModuleFilenameTemplate` to `[absolute-resource-path]`.**\n\n⚠️ **Note: If you are using a custom rspack config, then the serverless plugin passed to your config function will have `offlineMode` set to true.**\n\n\n## Known Issues\n\n  - Invoke Local does not work with ESM enabled when using serverless V3: [ISSUE-11308](https://github.com/serverless/serverless/issues/11308#issuecomment-1719297694)\n\n\n---\n\n---\n\n---\n\nInspired by [serverless-plugin-typescript](https://github.com/prisma-labs/serverless-plugin-typescript), [serverless-webpack](https://github.com/serverless-heaven/serverless-webpack) and [serverless-esbuild](https://github.com/floydspace/serverless-esbuild)\n\n[ico-serverless]: http://public.serverless.com/badges/v3.svg\n[ico-npm]: https://img.shields.io/npm/v/@kitchenshelf/serverless-rspack.svg\n[ico-build]: https://github.com/kitchenshelf/serverless-rspack/actions/workflows/ci.yml/badge.svg\n[link-serverless]: https://www.serverless.com/\n[link-npm]: https://www.npmjs.com/package/@kitchenshelf/serverless-rspack\n[link-build]: https://github.com/kitchenshelf/serverless-rspack/actions/workflows/ci.yml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitchenshelf%2Fserverless-rspack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitchenshelf%2Fserverless-rspack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitchenshelf%2Fserverless-rspack/lists"}