Registry / devops / esbuild-plugin-mxn-copy

esbuild-plugin-mxn-copy

JSON →
library1.0.1jsnpmunverified

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.

npm install esbuild-plugin-mxn-copy
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-MXN
E
esbuild-plugin-mxn-copy
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'
const esbuildMxnCopy = require('esbuild-plugin-mxn-copy')
ESM-only package; CommonJS require will fail. Use dynamic import if needed: const esbuildMxnCopy = (await import('esbuild-plugin-mxn-copy')).default;
build
import { build } from 'esbuild'; import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'
const { build } = require('esbuild'); const esbuildMxnCopy = require('esbuild-plugin-mxn-copy')
esbuild also requires ESM import. Mixing require and import may cause issues.

Creates an esbuild build script that copies HTML, SVG, and a directory into the output using the copy plugin.

import { build } from 'esbuild'; import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'; build({ entryPoints: ['src/index.js'], bundle: true, outdir: 'dist', plugins: [ esbuildMxnCopy({ copy: [ { from: 'src/index.html', to: 'dist/index.html' }, { from: 'src/logo.svg', to: 'dist/' }, { from: 'src/preact', to: 'dist/preact' } ], verbose: true }) ] }).catch(() => process.exit(1));
Debug
Known issues
gotchaPlugin does not support glob patterns; each copy entry must be an explicit path.
fix
Use array of {from, to} objects for each file or directory. For globs, consider alternatives like @chialab/esbuild-plugin-copy.
affects: >=1.0
gotchaThe 'to' path in copy entries is relative to the project root, not the outdir. Destination is exactly as specified.
fix
Ensure the 'to' path matches the desired output location; it does not automatically append to outdir.
affects: >=1.0
breakingPackage is ESM-only; requires Node.js >=12 or bundler that supports ESM.
fix
Use import syntax or dynamic import. For CommonJS projects, use import() or switch to a CommonJS-compatible copy plugin.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/esbuild-plugin-mxn-copy/index.js not supported.
Using require() on an ESM-only package.
fix
Change to import statement: import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'
TypeError: esbuildMxnCopy is not a function
Namespace import instead of default import.
fix
Use default import: import esbuildMxnCopy from 'esbuild-plugin-mxn-copy'
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-mxn-copy — npm install esbuild-plugin-mxn-copy · libregistry