@faststats/sourcemap-uploader-plugin
v0.5.3
Published
> [!IMPORTANT] > This package is in early development and not intended for production use. > It is only published for internal testing.
Readme
@faststats/sourcemap-uploader-plugin
[!IMPORTANT] This package is in early development and not intended for production use. It is only published for internal testing.
Unplugin-based sourcemap uploader that works across all unplugin adapters:
- Vite
- Rollup
- Rolldown
- Webpack
- Rspack
- esbuild
- Unloader
- Farm
- Bun
What it does
- injects build metadata into entry chunks at
globalThis.__SOURCEMAPS_BUILD__(esbuild injects it into every output file) - uploads generated sourcemaps to a backend endpoint
- uses a custom
buildId, the commit hash from CI or git, or a random ID - optionally deletes sourcemap files after successful upload
Usage
Create an API key under Project settings → Sourcemaps and pass it to the plugin:
import sourcemapsPlugin from "@faststats/sourcemap-uploader-plugin/vite";
export default {
build: { sourcemap: true },
plugins: [
sourcemapsPlugin({
authToken: process.env.FASTSTATS_SOURCEMAP_KEY,
deleteAfterUpload: true,
}),
],
};Every bundler has its own entry point: /vite, /rollup, /rolldown, /webpack, /rspack, /esbuild, /unloader, /farm and /bun.
Options
authToken: FastStats API key scoped to one project with thesourceMap:uploadpermissionendpoint: upload URL,https://sourcemaps.faststats.dev/v0/uploadby defaultenabled:trueby default; setfalseor pass(framework) => booleanto disable the plugin conditionallybuildId: custom build identifier; defaults to the commit hash from CI or gitmaxUploadBodyBytes: largest request body the plugin sends, 50 MB by default; builds are split into requests of about 8 MB (or this limit, if lower) that upload four at a timefailOnError:trueby default; setfalseto let the build succeed when the upload failsdeleteAfterUpload: remove sourcemap files after successful uploadglobalKey: runtime global key for build metadatafetchImpl: custom fetch implementationonUploadSuccess: callback after each uploaded request; requests complete in any orderonUploadError: callback when upload fails
Upload payload
The plugin sends POST /v0/upload with this JSON body:
{
"type": "javascript",
"buildId": "build-123",
"uploadedAt": "2026-04-01T12:00:00.000Z",
"files": [
{
"fileName": "assets/app.js.map",
"content": "{...}"
}
]
}Tests
bun run test