bunchee 4.4.5 → 4.4.7

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
@@ -481,13 +481,13 @@ function lint$1(pkg) {
481
481
  }
482
482
  }
483
483
  } else {
484
+ // Validate CJS package
484
485
  if (main && path__default.default.extname(main) === '.mjs') {
485
486
  state.badMainExtension = true;
486
487
  }
487
- // Validate CJS package
488
488
  if (exports) {
489
489
  if (typeof exports === 'string') {
490
- if (!hasCjsExtension(exports)) {
490
+ if (path__default.default.extname(exports) === '.mjs') {
491
491
  state.badMainExport = true;
492
492
  }
493
493
  }
@@ -523,7 +523,11 @@ function lint$1(pkg) {
523
523
  logger.warn('Cannot export `main` field with .mjs extension in CJS package, only .js extension is allowed');
524
524
  }
525
525
  if (state.badMainExport) {
526
- logger.warn('Cannot export `exports` field with .cjs extension in ESM package, only .mjs and .js extensions are allowed');
526
+ if (isESM) {
527
+ logger.warn('Cannot export `exports` field with .cjs extension in ESM package, only .mjs and .js extensions are allowed');
528
+ } else {
529
+ logger.warn('Cannot export `exports` field with .mjs extension in CJS package, only .js and .cjs extensions are allowed');
530
+ }
527
531
  }
528
532
  if (state.invalidExportsFieldType) {
529
533
  logger.warn('Invalid exports field type, only object or string is allowed');
@@ -554,7 +558,7 @@ function lint$1(pkg) {
554
558
  }
555
559
  }
556
560
 
557
- var version = "4.4.5";
561
+ var version = "4.4.7";
558
562
 
559
563
  function relativify(path) {
560
564
  return path.startsWith('.') ? path : `./${path}`;
package/dist/index.js CHANGED
@@ -1017,6 +1017,9 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
1017
1017
  checkJs: false,
1018
1018
  declarationMap: false,
1019
1019
  skipLibCheck: true,
1020
+ // preserveSymlinks should always be set to false to avoid issues with
1021
+ // resolving types from <reference> from node_modules
1022
+ preserveSymlinks: false,
1020
1023
  target: 'ESNext',
1021
1024
  ...!tsCompilerOptions.jsx ? {
1022
1025
  jsx: 'react-jsx'
@@ -1176,6 +1179,7 @@ async function buildOutputConfigs(entry, bundleConfig, exportCondition, buildCon
1176
1179
  // Add esm mark and interop helper if esm export is detected
1177
1180
  const useEsModuleMark = hasEsmExport(exportPaths, tsCompilerOptions);
1178
1181
  const absoluteOutputFile = path.resolve(cwd, bundleConfig.file);
1182
+ const outputFileExtension = path.extname(absoluteOutputFile);
1179
1183
  const name = filePathWithoutExtension(absoluteOutputFile);
1180
1184
  var _exportCondition_export_types;
1181
1185
  const dtsFile = path.resolve(cwd, dts ? bundleConfig.file : (_exportCondition_export_types = exportCondition.export.types) != null ? _exportCondition_export_types : getExportFileTypePath(bundleConfig.file));
@@ -1195,7 +1199,10 @@ async function buildOutputConfigs(entry, bundleConfig, exportCondition, buildCon
1195
1199
  strict: false,
1196
1200
  sourcemap: bundleConfig.sourcemap,
1197
1201
  manualChunks: createSplitChunks(pluginContext.moduleDirectiveLayerMap, entryFiles),
1198
- chunkFileNames: '[name]-[hash].js',
1202
+ chunkFileNames () {
1203
+ const ext = format === 'cjs' && outputFileExtension === '.cjs' ? 'cjs' : 'js';
1204
+ return '[name]-[hash].' + ext;
1205
+ },
1199
1206
  // By default in rollup, when creating multiple chunks, transitive imports of entry chunks
1200
1207
  // will be added as empty imports to the entry chunks. Disable to avoid imports hoist outside of boundaries
1201
1208
  hoistTransitiveImports: false,
@@ -1698,11 +1705,12 @@ function logWatcherBuildTime(result) {
1698
1705
  let startTime = 0;
1699
1706
  result.map((watcher)=>{
1700
1707
  function start() {
1701
- if (startTime === 0) startTime = perf_hooks.performance.now();
1708
+ if (watcherCounter === 0) startTime = perf_hooks.performance.now();
1709
+ watcherCounter++;
1702
1710
  }
1703
1711
  function end() {
1704
- watcherCounter++;
1705
- if (watcherCounter === result.length) {
1712
+ watcherCounter--;
1713
+ if (watcherCounter === 0) {
1706
1714
  logger.info(`Build in ${(perf_hooks.performance.now() - startTime).toFixed(2)}ms`);
1707
1715
  }
1708
1716
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "4.4.5",
3
+ "version": "4.4.7",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": "./dist/bin/cli.js",
6
6
  "main": "./dist/index.js",