{"id":25374,"library":"esbuild-plugin-mxn-copy","title":"esbuild-plugin-mxn-copy","description":"Esbuild plugin to copy assets (files and directories) into the output directory during bundling. Version 1.0.1 is stable with ~12.7kb size. Alternatives include @chialab/esbuild-plugin-copy (more configurable) and esbuild-plugin-copy (glob patterns). This plugin uses explicit from/to objects, supports verbose logging and a restrictive mode to limit directory access.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/ZimNovich/esbuild-plugin-mxn-copy","tags":["javascript","esbuild","esbuild-plugin","bundle","copy","assets"],"install":[{"cmd":"npm install esbuild-plugin-mxn-copy","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-mxn-copy","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-mxn-copy","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require will fail. Use dynamic import if needed: const esbuildMxnCopy = (await import('esbuild-plugin-mxn-copy')).default;","wrong":"const esbuildMxnCopy = require('esbuild-plugin-mxn-copy')","symbol":"default","correct":"import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'"},{"note":"esbuild also requires ESM import. Mixing require and import may cause issues.","wrong":"const { build } = require('esbuild'); const esbuildMxnCopy = require('esbuild-plugin-mxn-copy')","symbol":"build","correct":"import { build } from 'esbuild'; import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport esbuildMxnCopy from 'esbuild-plugin-mxn-copy';\n\nbuild({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outdir: 'dist',\n  plugins: [\n    esbuildMxnCopy({\n      copy: [\n        { from: 'src/index.html', to: 'dist/index.html' },\n        { from: 'src/logo.svg', to: 'dist/' },\n        { from: 'src/preact', to: 'dist/preact' }\n      ],\n      verbose: true\n    })\n  ]\n}).catch(() => process.exit(1));","lang":"typescript","description":"Creates an esbuild build script that copies HTML, SVG, and a directory into the output using the copy plugin."},"warnings":[{"fix":"Use array of {from, to} objects for each file or directory. For globs, consider alternatives like @chialab/esbuild-plugin-copy.","message":"Plugin does not support glob patterns; each copy entry must be an explicit path.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Ensure the 'to' path matches the desired output location; it does not automatically append to outdir.","message":"The 'to' path in copy entries is relative to the project root, not the outdir. Destination is exactly as specified.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use import syntax or dynamic import. For CommonJS projects, use import() or switch to a CommonJS-compatible copy plugin.","message":"Package is ESM-only; requires Node.js >=12 or bundler that supports ESM.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change to import statement: import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'","cause":"Using require() on an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/esbuild-plugin-mxn-copy/index.js not supported."},{"fix":"Use default import: import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'","cause":"Namespace import instead of default import.","error":"TypeError: esbuildMxnCopy is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}