bunchee 5.2.0-beta.1 → 5.2.0

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
@@ -133,13 +133,6 @@ const logger = {
133
133
  console.log(color('green')('✓'), ...arg);
134
134
  }
135
135
  };
136
- function paint(prefix, prefixColor, ...arg) {
137
- if (pc.isColorSupported) {
138
- console.log(pc[prefixColor](prefix), ...arg);
139
- } else {
140
- console.log(prefix, ...arg);
141
- }
142
- }
143
136
 
144
137
  function exit(err) {
145
138
  logger.error(err);
@@ -477,7 +470,7 @@ function lint$1(pkg) {
477
470
  }
478
471
  }
479
472
 
480
- var version = "5.2.0-beta.1";
473
+ var version = "5.2.0";
481
474
 
482
475
  function relativify(path) {
483
476
  return path.startsWith('.') ? path : `./${path}`;
@@ -1026,24 +1019,34 @@ async function run(args) {
1026
1019
  await lint(cwd);
1027
1020
  const { default: ora } = await import('ora');
1028
1021
  const spinner = ora({
1029
- text: 'Building...\n',
1022
+ text: 'Building...\n\n',
1030
1023
  color: 'green'
1031
1024
  });
1032
- function stopSpinner() {
1025
+ function stopSpinner(text) {
1033
1026
  if (spinner.isSpinning) {
1034
- spinner.stop();
1027
+ spinner.clear();
1028
+ console.log();
1029
+ if (text) {
1030
+ spinner.stopAndPersist({
1031
+ symbol: '✔',
1032
+ text
1033
+ });
1034
+ } else {
1035
+ spinner.stop();
1036
+ }
1035
1037
  }
1036
1038
  }
1037
1039
  let initialBuildContext;
1038
1040
  function onBuildStart(buildContext) {
1039
1041
  initialBuildContext = buildContext;
1042
+ spinner.start();
1040
1043
  }
1041
1044
  function onBuildEnd(assetJobs) {
1045
+ // Stop spinner before logging output files and sizes on build end
1042
1046
  if (watch) {
1047
+ stopSpinner('');
1043
1048
  logWatcherBuildTime(assetJobs);
1044
1049
  } else {
1045
- // Stop spinner before logging output files and sizes
1046
- stopSpinner();
1047
1050
  if (assetJobs.length === 0) {
1048
1051
  logger.warn('The "src" directory does not contain any entry files. ' + 'For proper usage, please refer to the following link: ' + 'https://github.com/huozhi/bunchee#usage');
1049
1052
  }
@@ -1058,11 +1061,12 @@ async function run(args) {
1058
1061
  onBuildStart,
1059
1062
  onBuildEnd
1060
1063
  };
1061
- spinner.start();
1064
+ if (watch) {
1065
+ logger.log(`Watching project ${cwd}...`);
1066
+ }
1062
1067
  try {
1063
1068
  await index_js.bundle(cliEntry, bundleConfig);
1064
1069
  } catch (err) {
1065
- stopSpinner();
1066
1070
  if (err.name === 'NOT_EXISTED') {
1067
1071
  buildError = {
1068
1072
  digest: 'bunchee:not-existed',
@@ -1080,13 +1084,9 @@ async function run(args) {
1080
1084
  }
1081
1085
  }
1082
1086
  // watching mode
1083
- if (watch) {
1084
- logger.log(`Watching project ${cwd}...`);
1085
- return;
1087
+ if (!watch) {
1088
+ stopSpinner(`bunchee ${version} build completed`);
1086
1089
  }
1087
- // build mode
1088
- logger.log();
1089
- paint('✓', 'green', `bunchee ${version} build completed`);
1090
1090
  }
1091
1091
  async function main() {
1092
1092
  let params, error;
@@ -1112,7 +1112,7 @@ function logWatcherBuildTime(result) {
1112
1112
  function end() {
1113
1113
  watcherCounter--;
1114
1114
  if (watcherCounter === 0) {
1115
- logger.info(`Build in ${(perf_hooks.performance.now() - startTime).toFixed(2)}ms`);
1115
+ logger.info(`Built in ${(perf_hooks.performance.now() - startTime).toFixed(2)}ms`);
1116
1116
  }
1117
1117
  }
1118
1118
  watcher.on('event', (event)=>{
package/dist/index.js CHANGED
@@ -556,6 +556,18 @@ async function collectEntriesFromParsedExports(cwd, parsedExportsInfo, sourceFil
556
556
  }
557
557
  // output exports match
558
558
  if (matchedExportType === entryExportPathType || !hasSpecialEntry && matchedExportType !== 'default') {
559
+ // When we dealing with special export conditions, we need to make sure
560
+ // the outputs won't override the default export output paths.
561
+ // e.g. We have './index' -> { default: 'index.js', development: 'index.development.js' };
562
+ // When we generate './index.react-server' -> { 'react-server': 'index.react-server.js' },
563
+ // Normalize the entryExportPath to './index' first and check if it already exists with output paths.
564
+ const normalizedEntryExportPath = stripSpecialCondition(entryExportPath);
565
+ if (// The entry already exists, e.g. normalize './index.react-server' to './index'
566
+ entries[normalizedEntryExportPath] && // Is special export condition
567
+ entryExportPathType !== 'default' && // The extracted special condition is not the current loop one.
568
+ entryExportPathType !== matchedExportType) {
569
+ continue;
570
+ }
559
571
  const exportMap = entries[entryExportPath].export;
560
572
  exportMap[outputComposedExportType] = outputPath;
561
573
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "5.2.0-beta.1",
3
+ "version": "5.2.0",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": "./dist/bin/cli.js",
6
6
  "main": "./dist/index.js",