esbuild-multicontext
Advanced tools
Comparing version 0.13.0 to 0.14.0
{ | ||
"name": "esbuild-multicontext", | ||
"description": "Minimal wrapper over esbuild's context API", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"license": "MIT", | ||
@@ -40,4 +40,4 @@ "type": "module", | ||
"next": "bumpp", | ||
"test": "uvu", | ||
"test:ci": "c8 uvu", | ||
"test": "uvu -r tsm", | ||
"test:ci": "c8 uvu -r tsm", | ||
"prepare": "npm run build" | ||
@@ -47,12 +47,15 @@ }, | ||
"dependencies": { | ||
"chokidar": "^3.6.0", | ||
"@types/sinon": "^17.0.3", | ||
"chokidar": "^4.0.0", | ||
"defu": "^6.1.3", | ||
"esbuild": "^0.23.0", | ||
"esbuild": "^0.24.0", | ||
"sinon": "^19.0.2", | ||
"tiny-glob": "^0.2.9" | ||
}, | ||
"devDependencies": { | ||
"@barelyhuman/prettier-config": "^1.1.0", | ||
"@barelyhuman/prettier-config": "^2.0.2", | ||
"@types/node": "^22.0.0", | ||
"bumpp": "^9.2.0", | ||
"bumpp": "^10.0.1", | ||
"c8": "^10.1.2", | ||
"kleur": "^4.1.5", | ||
"prettier": "^3.1.0", | ||
@@ -62,2 +65,3 @@ "rollup": "^4.18.0", | ||
"tsc-prog": "^2.3.0", | ||
"tsm": "^2.3.0", | ||
"tsx": "^4.6.1", | ||
@@ -64,0 +68,0 @@ "typescript": "^5.5.3", |
@@ -5,17 +5,67 @@ # esbuild-multicontext | ||
- [esbuild-multicontext](#esbuild-multicontext) | ||
- [What and Why?](#what-and-why) | ||
- [Usage](#usage) | ||
- [Recommended: `createContainer`](#recommended-createcontainer) | ||
- [Deprecated: `createContext`](#deprecated-createcontext) | ||
- [License](#license) | ||
Minimal wrapper over esbuild's context API | ||
## What and Why ? | ||
## What and Why? | ||
When working with modern codebases, there's always more than one esbuild config | ||
in place for either bundling server separately or the client separately and | ||
managing mulitple esbuild instances isn't recommended. `esbuild` provides a | ||
`context` API for long running esbuild tasks like watching and serving client | ||
bundles. This package wraps the context API with a very tiny wrapper to make it | ||
easier to write build tooling scripts without having to manage esbuild | ||
instances. | ||
When working with modern codebases, there's always more than one esbuild config in place for either bundling server separately or the client separately and managing multiple esbuild instances isn't recommended. `esbuild` provides a `context` API for long-running esbuild tasks like watching and serving client bundles. This package wraps the context API with a very tiny wrapper to make it easier to write build tooling scripts without having to manage esbuild instances. | ||
## Usage | ||
### Recommended: `createContainer` | ||
The `createContainer` API is the recommended way to manage multiple esbuild contexts. | ||
```js | ||
import { createContainer } from 'esbuild-multicontext' | ||
const container = createContainer() | ||
// Create a context with a specific configuration | ||
container.createContext('esm', { | ||
entryPoints: ['./src/index.js'], | ||
outdir: './dist/esm', | ||
format: 'esm', | ||
outExtension: { | ||
'.js': '.mjs', | ||
}, | ||
}) | ||
// Build all contexts | ||
const buildResults = await container.build() | ||
console.log(buildResults) | ||
// Run in development mode with file watching | ||
const devOptions = { | ||
dirs: ['src'], | ||
ignored: (filepath) => false, | ||
watchOptions: { | ||
shouldRebuild: (event, filepath) => true, | ||
chokidar: {}, | ||
}, | ||
onBuild: (result, triggeredBy) => { | ||
console.log('Build completed', result, triggeredBy) | ||
}, | ||
} | ||
const { close } = await container.dev(devOptions) | ||
// Close the watcher when done | ||
await close() | ||
``` | ||
### Deprecated: `createContext` | ||
The `createContext` API is deprecated and will be removed in future versions. Please use the `createContainer` API instead. | ||
```js | ||
import { createContext, CONSTANTS } from 'esbuild-multicontext' | ||
@@ -74,4 +124,5 @@ | ||
## License | ||
[MIT](/LICENSE) |
@@ -5,4 +5,15 @@ import esbuild from 'esbuild' | ||
import { Container } from './container.js' | ||
export * from './container.js' | ||
/** | ||
* @deprecated use `createContainer` API instead | ||
*/ | ||
export function createContext(initial: esbuild.BuildOptions) { | ||
return new ContextManager(initial) | ||
} | ||
export function createContainer() { | ||
return new Container(esbuild) | ||
} |
@@ -21,2 +21,5 @@ import chokidar from 'chokidar' | ||
/** | ||
* @deprecated use `createContainer` API handles watching internally | ||
*/ | ||
export const createContextWatcher = (context: ContextRebuilder) => { | ||
@@ -41,5 +44,5 @@ const watchers: chokidar.FSWatcher[] = [] | ||
} | ||
const builder = () => context.build.bind(context) | ||
return (globPattern, { root, onEvent, onBuild }: Options = { root: '.' }) => { | ||
@@ -46,0 +49,0 @@ syncify(globPattern, root, () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
74776
1956
127
6
13
13
5
+ Added@types/sinon@^17.0.3
+ Addedsinon@^19.0.2
+ Added@esbuild/aix-ppc64@0.24.2(transitive)
+ Added@esbuild/android-arm@0.24.2(transitive)
+ Added@esbuild/android-arm64@0.24.2(transitive)
+ Added@esbuild/android-x64@0.24.2(transitive)
+ Added@esbuild/darwin-arm64@0.24.2(transitive)
+ Added@esbuild/darwin-x64@0.24.2(transitive)
+ Added@esbuild/freebsd-arm64@0.24.2(transitive)
+ Added@esbuild/freebsd-x64@0.24.2(transitive)
+ Added@esbuild/linux-arm@0.24.2(transitive)
+ Added@esbuild/linux-arm64@0.24.2(transitive)
+ Added@esbuild/linux-ia32@0.24.2(transitive)
+ Added@esbuild/linux-loong64@0.24.2(transitive)
+ Added@esbuild/linux-mips64el@0.24.2(transitive)
+ Added@esbuild/linux-ppc64@0.24.2(transitive)
+ Added@esbuild/linux-riscv64@0.24.2(transitive)
+ Added@esbuild/linux-s390x@0.24.2(transitive)
+ Added@esbuild/linux-x64@0.24.2(transitive)
+ Added@esbuild/netbsd-arm64@0.24.2(transitive)
+ Added@esbuild/netbsd-x64@0.24.2(transitive)
+ Added@esbuild/openbsd-arm64@0.24.2(transitive)
+ Added@esbuild/openbsd-x64@0.24.2(transitive)
+ Added@esbuild/sunos-x64@0.24.2(transitive)
+ Added@esbuild/win32-arm64@0.24.2(transitive)
+ Added@esbuild/win32-ia32@0.24.2(transitive)
+ Added@esbuild/win32-x64@0.24.2(transitive)
+ Added@sinonjs/commons@3.0.1(transitive)
+ Added@sinonjs/fake-timers@13.0.5(transitive)
+ Added@sinonjs/samsam@8.0.2(transitive)
+ Added@sinonjs/text-encoding@0.7.3(transitive)
+ Added@types/sinon@17.0.3(transitive)
+ Added@types/sinonjs__fake-timers@8.1.5(transitive)
+ Addedchokidar@4.0.3(transitive)
+ Addeddiff@7.0.0(transitive)
+ Addedesbuild@0.24.2(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedjust-extend@6.2.0(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addednise@6.1.1(transitive)
+ Addedpath-to-regexp@8.2.0(transitive)
+ Addedreaddirp@4.1.2(transitive)
+ Addedsinon@19.0.2(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtype-detect@4.0.84.1.0(transitive)
- Removed@esbuild/aix-ppc64@0.23.1(transitive)
- Removed@esbuild/android-arm@0.23.1(transitive)
- Removed@esbuild/android-arm64@0.23.1(transitive)
- Removed@esbuild/android-x64@0.23.1(transitive)
- Removed@esbuild/darwin-arm64@0.23.1(transitive)
- Removed@esbuild/darwin-x64@0.23.1(transitive)
- Removed@esbuild/freebsd-arm64@0.23.1(transitive)
- Removed@esbuild/freebsd-x64@0.23.1(transitive)
- Removed@esbuild/linux-arm@0.23.1(transitive)
- Removed@esbuild/linux-arm64@0.23.1(transitive)
- Removed@esbuild/linux-ia32@0.23.1(transitive)
- Removed@esbuild/linux-loong64@0.23.1(transitive)
- Removed@esbuild/linux-mips64el@0.23.1(transitive)
- Removed@esbuild/linux-ppc64@0.23.1(transitive)
- Removed@esbuild/linux-riscv64@0.23.1(transitive)
- Removed@esbuild/linux-s390x@0.23.1(transitive)
- Removed@esbuild/linux-x64@0.23.1(transitive)
- Removed@esbuild/netbsd-x64@0.23.1(transitive)
- Removed@esbuild/openbsd-arm64@0.23.1(transitive)
- Removed@esbuild/openbsd-x64@0.23.1(transitive)
- Removed@esbuild/sunos-x64@0.23.1(transitive)
- Removed@esbuild/win32-arm64@0.23.1(transitive)
- Removed@esbuild/win32-ia32@0.23.1(transitive)
- Removed@esbuild/win32-x64@0.23.1(transitive)
- Removedanymatch@3.1.3(transitive)
- Removedbinary-extensions@2.3.0(transitive)
- Removedbraces@3.0.3(transitive)
- Removedchokidar@3.6.0(transitive)
- Removedesbuild@0.23.1(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfsevents@2.3.3(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedis-binary-path@2.1.0(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removednormalize-path@3.0.0(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedreaddirp@3.6.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
Updatedchokidar@^4.0.0
Updatedesbuild@^0.24.0