{"id":21283,"library":"esbuild-plugin-umd-wrapper","title":"esbuild-plugin-umd-wrapper","description":"An esbuild plugin that wraps bundled JavaScript output into UMD format, supporting AMD, CommonJS, and global variable exports. Version 3.0.0 is the latest stable release, actively maintained. It integrates seamlessly with esbuild's build pipeline, automatically adjusting the format to CJS before wrapping. Key differentiators: lightweight, zero-config, and compatible with esbuild's build options. It includes TypeScript declarations and allows customization of library name and wrapper options. Works with esbuild 0.8+.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/inqnuam/esbuild-plugin-umd-wrapper","tags":["javascript","esbuild","plugin","umd","amd","wrapper","requirejs","define","typescript"],"install":[{"cmd":"npm install esbuild-plugin-umd-wrapper","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-umd-wrapper","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-umd-wrapper","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; the plugin hooks into esbuild's build process","package":"esbuild","optional":false}],"imports":[{"note":"Named export, not default. TypeScript included.","wrong":"import umdWrapper from 'esbuild-plugin-umd-wrapper'","symbol":"umdWrapper","correct":"import { umdWrapper } from 'esbuild-plugin-umd-wrapper'"},{"note":"CommonJS destructure required.","wrong":"const umdWrapper = require('esbuild-plugin-umd-wrapper')","symbol":"umdWrapper","correct":"const { umdWrapper } = require('esbuild-plugin-umd-wrapper')"},{"note":"Type import for options interface.","symbol":"UmbrellaOptions","correct":"import type { UmbrellaOptions } from 'esbuild-plugin-umd-wrapper'"}],"quickstart":{"code":"const esbuild = require('esbuild');\nconst { umdWrapper } = require('esbuild-plugin-umd-wrapper');\n\nesbuild.build({\n  entryPoints: ['src/index.js'],\n  outdir: 'dist',\n  bundle: true,\n  format: 'umd', // plugin will override to 'cjs' internally\n  plugins: [umdWrapper({ libraryName: 'MyLib' })],\n}).then(result => console.log(result))\n  .catch(() => process.exit(1));","lang":"javascript","description":"Uses esbuild-plugin-umd-wrapper to bundle 'src/index.js' into UMD format with a custom library name 'MyLib'."},"warnings":[{"fix":"Use module.exports = myFunc or exports = myFunc instead of export default.","message":"When export default is used, the output is not directly callable; it becomes an object with __esModule and default property.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid running esbuild.build calls concurrently that share the same options object. Use sequential builds or deep clone the options.","message":"Concurrent esbuild builds reusing the same options object reference may produce unexpected output because the plugin modifies banner/footer on the options object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you need the format to remain 'umd' for other plugins, update your build pipeline accordingly. The plugin will still produce UMD output.","message":"Version 3.0.0 changed internal behavior: plugin now forces format to 'cjs' before executing, which may affect plugins that rely on format being 'umd' during build.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Set format: 'umd' or format: 'cjs' in esbuild build options.","cause":"esbuild format not set to 'cjs' or 'umd'.","error":"Error: The plugin \"umd-wrapper\" must be used with esbuild format \"cjs\" or \"umd\"."},{"fix":"Use import { umdWrapper } from 'esbuild-plugin-umd-wrapper' or const { umdWrapper } = require('esbuild-plugin-umd-wrapper').","cause":"Incorrect import: default import used instead of named import.","error":"TypeError: umdWrapper is not a function"},{"fix":"Run npm install -D esbuild-plugin-umd-wrapper or yarn add -D esbuild-plugin-umd-wrapper.","cause":"Package not installed or Node.js resolution issue.","error":"Cannot find module 'esbuild-plugin-umd-wrapper'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}