Socket
Socket
Sign inDemoInstall

bunchee

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunchee - npm Package Compare versions

Comparing version 2.0.0-beta.5 to 2.0.0

2

dist/cli.js

@@ -90,3 +90,3 @@ #!/usr/bin/env node

var version = "2.0.0-beta.5";
var version = "2.0.0";

@@ -93,0 +93,0 @@ var helpMessage = '\nUsage: bunchee [options]\n\nOptions:\n -v, --version output the version number\n -w, --watch watch src files changes\n -m, --minify compress output. false by default\n -o, --output <file> specify output filename\n -f, --format <format> specify bundle type: "esm", "cjs", "umd". "esm" by default\n -e, --external <mod> specify an external dependency\n --target <target> js features target: swc target es versions. "es5" by default\n --runtime <runtime> build runtime: "nodejs", "browser". "browser" by default\n --sourcemap enable sourcemap generation, false by default\n --cwd <cwd> specify current working directory\n -h, --help output usage information\n';

{
"name": "bunchee",
"version": "2.0.0-beta.5",
"version": "2.0.0",
"description": "zero config bundler for js/ts/jsx libraries",

@@ -5,0 +5,0 @@ "bin": {

@@ -57,3 +57,3 @@ # bunchee

"import": "dist/index.mjs",
"module": "dist/index.esm.js" // module condition
"module": "dist/index.esm.js"
},

@@ -89,12 +89,4 @@ "scripts": {

### API
Run bunchee via CLI
```js
import { bundle } from 'bunchee'
// options is same to CLI options
await bundle(entryFilePath, options)
```
#### Example Scripts
```sh

@@ -109,4 +101,13 @@ cd <project-root-dir>

### Using Typescript
### Node.js API
```js
import { bundle } from 'bunchee'
// options is same to CLI options
await bundle(entryFilePath, options)
```
### Typescript
By default bunchee includes Typescript v3.9.x inside as a dependency. If you want to use your own version, just install typescript as another dev dependency then bunchee will automatically pick it.

@@ -118,2 +119,52 @@

Create `tsconfig.json` to specify any compiler options for TypeScript.
This library requires at least [TypeScript 3.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html).
## Advanced
### Multiple Exports
While `exports` filed is becoming the standard of exporting in node.js, bunchee also supports to build multiple exports all in one command.
What you need to do is just add an entry file with the name (`[name].[ext]`) that matches the exported name from exports field in package.json. For instance:
* `index.ts` will match `"."` export name or the if there's only one main export.
* `lite.ts` will match `"./lite"` export name.
The build script will be simplified to just `bunchee` in package.json without configure any input sources for each exports. Of course you can still specify other arguments as you need.
#### How it works
Assuming you have main entry export `"."` and subpath export `"./lite"` with different exports condition listed in package.json
```json
{
"name": "example",
"scripts": {
"build": "bunchee"
},
"exports": {
"./lite": "./dist/lite.js"
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
}
}
```
Then you need to add two entry files `index.ts` and `lite.ts` in project root directory to match the export name `"."` and `"./lite"`, bunchee will associate these entry files with export names then use them as input source and output paths information.
```
- example/
|- lite.ts
|- index.ts
|- src/
|- package.json
```
### License
MIT
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