{"id":25326,"library":"esbuild-plugin-copy-watch","title":"esbuild-plugin-copy-watch","description":"An esbuild plugin that copies files from specified source patterns to a destination directly within the esbuild build process. Version 2.3.1 is the current stable release, with active maintenance as of 2024. It supports glob patterns and optional exclusion filters, allowing developers to copy assets like static files, configs, or HTML alongside bundled JavaScript output. Unlike manual copy steps or post-build scripts, this plugin integrates with esbuild's watch mode to re-copy files on each rebuild. It also offers a `forceCopyOnRebuild` option to force recopy even when sources are unchanged. TypeScript types are included for better IDE support.","status":"active","version":"2.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/tinchoz49/esbuild-plugin-copy-watch","tags":["javascript","esbuild","plugin","copy","watch","typescript"],"install":[{"cmd":"npm install esbuild-plugin-copy-watch","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-copy-watch","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-copy-watch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to function as a plugin; the plugin relies on esbuild's plugin API and watch mode","package":"esbuild","optional":false}],"imports":[{"note":"ESM-only; CommonJS require will not work. Use import or dynamic import.","wrong":"const copy = require('esbuild-plugin-copy-watch')","symbol":"default","correct":"import copy from 'esbuild-plugin-copy-watch'"},{"note":"Export is default only; there is no named export. Verified that only default export exists.","wrong":null,"symbol":"copyPlugin (if named export)","correct":"import { copy as copyPlugin } from 'esbuild-plugin-copy-watch'"},{"note":"TypeScript types are bundled in package; direct import from module root is correct.","wrong":"import copy from 'esbuild-plugin-copy-watch/dist/index.js'","symbol":"with TypeScript","correct":"import copy from 'esbuild-plugin-copy-watch'"}],"quickstart":{"code":"import esbuild from 'esbuild'\nimport copy from 'esbuild-plugin-copy-watch'\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    copy({\n      paths: [\n        { from: 'static/**', to: 'static' },\n        { from: ['config/*.js', '!config/private.js'], to: 'config' },\n      ],\n      forceCopyOnRebuild: false,\n    })\n  ]\n})","lang":"typescript","description":"Copies files matching 'static/**' to a 'static' directory in the output, and copies config JS files excluding 'private.js', with no force recopy."},"warnings":[{"fix":"Use default import: import copy from 'esbuild-plugin-copy-watch'","message":"Default export changed from named export to default export in v2.0.0","severity":"breaking","affected_versions":">=2.0.0 <2.0.0"},{"fix":"Set forceCopyOnRebuild to true if needed; see docs for alternative","message":"The option 'forceCopyOnRebuild' may be removed in future versions; no deprecation warning yet but usage is discouraged","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Update esbuild to version 0.8.0 or later","message":"Plugin requires esbuild >=0.8.0; older esbuild versions may cause build failures","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Wrap pattern and negation in an array: ['src/**', '!src/private.js']","message":"Glob patterns with negation must be in array form; passing a string with negation will not work","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: npm install esbuild-plugin-copy-watch","cause":"Package not installed or missing from node_modules","error":"Error: Could not resolve 'esbuild-plugin-copy-watch'"},{"fix":"Use import copy from 'esbuild-plugin-copy-watch' and ensure your project is ESM (type: module in package.json)","cause":"Using CommonJS require instead of ESM import, or calling the default export incorrectly","error":"TypeError: copy is not a function"},{"fix":"Update esbuild: npm install esbuild@latest","cause":"Plugin requires esbuild >=0.8.0; current installed esbuild is older","error":"Error: esbuild version 0.8.0 or higher is required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}