New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-multicontext

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-multicontext - npm Package Compare versions

Comparing version 0.13.0 to 0.14.0

src/container.ts

18

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc