bunchee icon indicating copy to clipboard operation
bunchee copied to clipboard

feat: custom config and multi entries

Open huozhi opened this issue 2 years ago • 0 comments

Introduce bunchee field in package.json for customize config for bunchee. Along with other basic configs bunchee.entry is a new field to specify entry files for single export or multiple ones. So you don't have to give more arguments for cli but can build multiple exports at the same time.

Use cases

Single entry with custom configs

{
  "bunchee": {
    "entry": "./src/index.js",
    "minify": false
  },
  "export": "./dist/index.js"
}

Multi entries

{
  "exports": {
    "./lite": "./dist/lite.js",
    "./client": {
      "require": "./dist/client/index.cjs",
      "import": "./dist/client/index.mjs"
    }
  },
  "bunchee": {
    "entry": {
      "./lite": "./lite/index.js",
      "./client": "./client/index.js"
    }
  }
}

Single entry + multiple exports with only ./ export

{
  "exports": {
    "./": "./dist/lite.js"
    "./package.json"
  },
  "bunchee": {
    "entry": "./src/lite.js"
   }
}

TODO

  • [x] single entry
  • [ ] watch mode

Tests

  • [x] single entry
  • [ ] typescript case

huozhi avatar Aug 06 '22 23:08 huozhi