Resolve alias webpack helper
Payload plugin that injects webpack resolve aliases to stub out server-only modules in the admin bundle.
Installation
pnpm add payload-plugin-resolve-alias About
This plugin solves a recurring webpack error in Payload's admin build where Node core modules like `util`, `express`, `express-session`, `passport`, and `nodemailer` fail to resolve because webpack 5 no longer polyfills them by default. It hooks into the `admin.webpack` config to add entries to `resolve.alias` that map those modules to `false`, telling webpack to emit an empty module instead of trying to bundle a server-only dependency for the browser. You register it in `payload.config.ts` as a normal Payload plugin. The `resolveAlias` function accepts multiple argument shapes: a plain object of `{ module: false }` pairs, an array of module names, or individual string names. It merges everything into one alias map and runs after any existing `admin.webpack` handler so your custom config is preserved. The package ships a `serverOnlyModules` constant listing the common offenders (`express`, `express-session`, `nodemailer`, `passport`, `util`), so the typical fix is a one-liner: `resolveAlias(serverOnlyModules, ['nodemailer'])`. Falsy arguments are skipped, which lets you pass conditional aliases guarded by environment checks. It targets Payload 1.x and works by transforming the `Config` object before it reaches the build. It does not add fields, collections, hooks, or endpoints. The one known limitation is that it cannot handle webpack alias configs defined as arrays.
Package info
- Package name
payload-plugin-resolve-alias- Latest version
0.1.0- Unpacked size
- 7 kB
- License
- MIT
- Weekly downloads
- 1.2k
- Last publish
- Nov 5, 2022
More from thgh
View profileSimilar plugins
More in Devtoolspayload-cli
CLI for direct access to PayloadCMS data for AI agents and humans.
agent API guide
Generate a live API reference and query guide for Payload CMS.
Markdown documentation sync
Syncs Markdown documentation with Payload CMS using Git.
OpenAPI
Generates OpenAPI specifications from Payload CMS configurations.
Puck visual page builder
Integrate Puck visual page builder with Payload CMS for drag-and-drop editing.
Dry Run
Test Payload create operations end-to-end without persisting, by rolling back the transaction after hooks and validation run.