bunchee 5.1.5 → 5.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -474,7 +474,7 @@ function lint$1(pkg) {
474
474
  }
475
475
  }
476
476
 
477
- var version = "5.1.5";
477
+ var version = "5.1.6";
478
478
 
479
479
  function relativify(path) {
480
480
  return path.startsWith('.') ? path : `./${path}`;
package/dist/index.js CHANGED
@@ -1485,22 +1485,25 @@ async function buildOutputConfigs(entry, bundleConfig, exportCondition, buildCon
1485
1485
  output: outputOptions
1486
1486
  };
1487
1487
  }
1488
- async function buildEntryConfig(bundleConfig, pluginContext, dts) {
1488
+ async function buildEntryConfig(bundleConfig, pluginContext, bundleEntryOptions) {
1489
1489
  const configs = [];
1490
1490
  const { entries } = pluginContext;
1491
1491
  for (const exportCondition of Object.values(entries)){
1492
- const rollupConfigs = await buildConfig(bundleConfig, exportCondition, pluginContext, dts);
1492
+ const rollupConfigs = await buildConfig(bundleConfig, exportCondition, pluginContext, bundleEntryOptions);
1493
1493
  configs.push(...rollupConfigs);
1494
1494
  }
1495
1495
  return configs;
1496
1496
  }
1497
- async function buildConfig(bundleConfig, exportCondition, pluginContext, dts) {
1497
+ async function buildConfig(bundleConfig, exportCondition, pluginContext, bundleEntryOptions) {
1498
1498
  const { file } = bundleConfig;
1499
1499
  const { pkg, cwd } = pluginContext;
1500
+ const { dts, isFromCli } = bundleEntryOptions;
1500
1501
  const entry = exportCondition.source;
1501
1502
  const outputExports = getExportsDistFilesOfCondition(pkg, exportCondition, cwd, dts);
1502
- // If there's nothing found, give a default output
1503
- if (outputExports.length === 0 && !pkg.bin) {
1503
+ // If it's CLI generation for JS asset and there's nothing found,
1504
+ // give a default output dist/index.js.
1505
+ // We don't do it for types generation or non-CLI bundle generation.
1506
+ if (!dts && isFromCli && outputExports.length === 0 && !pkg.bin) {
1504
1507
  const isEsmPkg = isESModulePackage(pkg.type);
1505
1508
  const defaultFormat = isEsmPkg ? 'esm' : 'cjs';
1506
1509
  outputExports.push({
@@ -1689,9 +1692,16 @@ function logOutputState(sizeCollector) {
1689
1692
  });
1690
1693
  }
1691
1694
 
1692
- async function createAssetRollupJobs(options, buildContext, { isFromCli, generateTypes }) {
1693
- const assetsConfigs = await buildEntryConfig(options, buildContext, false);
1694
- const typesConfigs = generateTypes ? await buildEntryConfig(options, buildContext, true) : [];
1695
+ async function createAssetRollupJobs(options, buildContext, bundleJobOptions) {
1696
+ const { isFromCli, generateTypes } = bundleJobOptions;
1697
+ const assetsConfigs = await buildEntryConfig(options, buildContext, {
1698
+ dts: false,
1699
+ isFromCli
1700
+ });
1701
+ const typesConfigs = generateTypes ? await buildEntryConfig(options, buildContext, {
1702
+ dts: true,
1703
+ isFromCli
1704
+ }) : [];
1695
1705
  const allConfigs = assetsConfigs.concat(typesConfigs);
1696
1706
  for (const config of allConfigs){
1697
1707
  if (options.clean && !isFromCli) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "5.1.5",
3
+ "version": "5.1.6",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": "./dist/bin/cli.js",
6
6
  "main": "./dist/index.js",
@@ -74,16 +74,16 @@
74
74
  "@types/jest": "29.0.0",
75
75
  "@types/node": "^20.4.1",
76
76
  "bunchee": "link:./",
77
- "husky": "^8.0.3",
77
+ "husky": "^9.0.11",
78
78
  "jest": "29.0.1",
79
- "lint-staged": "^13.2.3",
79
+ "lint-staged": "^15.2.2",
80
80
  "picocolors": "^1.0.0",
81
81
  "prettier": "^3.0.0",
82
82
  "react": "^18.2.0",
83
83
  "typescript": "^5.3.2"
84
84
  },
85
85
  "lint-staged": {
86
- "*.{ts,tsx,js,jsx,md,json,yml}": "prettier --write"
86
+ "*.{js,jsx,ts,tsx,md,json,yml,yaml}": "prettier --write"
87
87
  },
88
88
  "jest": {
89
89
  "moduleDirectories": [