bunchee 4.4.6 → 4.4.8

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
@@ -558,7 +558,7 @@ function lint$1(pkg) {
558
558
  }
559
559
  }
560
560
 
561
- var version = "4.4.6";
561
+ var version = "4.4.8";
562
562
 
563
563
  function relativify(path) {
564
564
  return path.startsWith('.') ? path : `./${path}`;
package/dist/index.js CHANGED
@@ -937,7 +937,7 @@ function getDefinedInlineVariables(envs, parsedExportCondition) {
937
937
  return alias;
938
938
  }
939
939
  async function buildInputConfig(entry, bundleConfig, exportCondition, buildContext, dts) {
940
- var _bundleConfig_file;
940
+ var _bundleConfig_file, _bundleConfig_file1;
941
941
  const { entries, pkg, cwd, tsOptions: { tsConfigPath, tsCompilerOptions }, pluginContext } = buildContext;
942
942
  const hasNoExternal = bundleConfig.external === null;
943
943
  var _bundleConfig_external;
@@ -983,7 +983,8 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
983
983
  };
984
984
  const sizePlugin = pluginContext.outputState.plugin(cwd);
985
985
  // common plugins for both dts and ts assets that need to be processed
986
- const aliasFormat = dts ? ((_bundleConfig_file = bundleConfig.file) == null ? void 0 : _bundleConfig_file.endsWith('.d.cts')) ? 'cjs' : 'esm' : bundleConfig.format;
986
+ // If it's a .d.ts file under non-ESM package or .d.cts file, use cjs types alias.
987
+ const aliasFormat = dts ? ((_bundleConfig_file = bundleConfig.file) == null ? void 0 : _bundleConfig_file.endsWith('.d.cts')) || ((_bundleConfig_file1 = bundleConfig.file) == null ? void 0 : _bundleConfig_file1.endsWith('.d.ts')) && !isESModulePackage(pkg.type) ? 'cjs' : 'esm' : bundleConfig.format;
987
988
  const commonPlugins = [
988
989
  json__default.default(),
989
990
  sizePlugin,
@@ -1179,6 +1180,7 @@ async function buildOutputConfigs(entry, bundleConfig, exportCondition, buildCon
1179
1180
  // Add esm mark and interop helper if esm export is detected
1180
1181
  const useEsModuleMark = hasEsmExport(exportPaths, tsCompilerOptions);
1181
1182
  const absoluteOutputFile = path.resolve(cwd, bundleConfig.file);
1183
+ const outputFileExtension = path.extname(absoluteOutputFile);
1182
1184
  const name = filePathWithoutExtension(absoluteOutputFile);
1183
1185
  var _exportCondition_export_types;
1184
1186
  const dtsFile = path.resolve(cwd, dts ? bundleConfig.file : (_exportCondition_export_types = exportCondition.export.types) != null ? _exportCondition_export_types : getExportFileTypePath(bundleConfig.file));
@@ -1198,7 +1200,10 @@ async function buildOutputConfigs(entry, bundleConfig, exportCondition, buildCon
1198
1200
  strict: false,
1199
1201
  sourcemap: bundleConfig.sourcemap,
1200
1202
  manualChunks: createSplitChunks(pluginContext.moduleDirectiveLayerMap, entryFiles),
1201
- chunkFileNames: '[name]-[hash].js',
1203
+ chunkFileNames () {
1204
+ const ext = format === 'cjs' && outputFileExtension === '.cjs' ? 'cjs' : 'js';
1205
+ return '[name]-[hash].' + ext;
1206
+ },
1202
1207
  // By default in rollup, when creating multiple chunks, transitive imports of entry chunks
1203
1208
  // will be added as empty imports to the entry chunks. Disable to avoid imports hoist outside of boundaries
1204
1209
  hoistTransitiveImports: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "4.4.6",
3
+ "version": "4.4.8",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": "./dist/bin/cli.js",
6
6
  "main": "./dist/index.js",