bunchee 4.2.10 → 4.2.11

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
@@ -115,7 +115,7 @@ async function fileExists(filePath) {
115
115
  }
116
116
  }
117
117
 
118
- var version = "4.2.10";
118
+ var version = "4.2.11";
119
119
 
120
120
  const helpMessage = `
121
121
  Usage: bunchee [options]
package/dist/index.js CHANGED
@@ -223,8 +223,8 @@ function resolveTypescript(cwd) {
223
223
  m.paths = module$1.Module._nodeModulePaths(cwd);
224
224
  try {
225
225
  ts = m.require('typescript');
226
- } catch (_) {
227
- console.error(_);
226
+ } catch (e) {
227
+ console.error(e);
228
228
  if (!hasLoggedTsWarning) {
229
229
  hasLoggedTsWarning = true;
230
230
  exit('Could not load TypeScript compiler. Try to install `typescript` as dev dependency');
@@ -727,22 +727,19 @@ function getBuildEnv(envs) {
727
727
  return envVars;
728
728
  }
729
729
  /**
730
- * return { '<pkg>/<export>': '<absolute source path> }
731
- */ function getEntriesAlias(entries) {
730
+ * return { '<absolute source path>': '<pkg>/<export>' }
731
+ */ function getReversedAlias(entries) {
732
732
  const alias = {};
733
733
  for (const [entryImportPath, exportCondition] of Object.entries(entries)){
734
- alias[entryImportPath] = exportCondition.source;
734
+ const exportType = entryImportPath.split('.')[1] // e.g. index.react-server, pick react-server
735
+ ;
736
+ if (!exportType) {
737
+ alias[exportCondition.source] = entryImportPath;
738
+ }
735
739
  }
736
740
  return alias;
737
741
  }
738
742
  async function buildInputConfig(entry, entries, pkg, options, cwd, { tsConfigPath, tsCompilerOptions }, pluginContext, dts) {
739
- const entriesAlias = getEntriesAlias(entries);
740
- const reversedAlias = {};
741
- for (const [key, value] of Object.entries(entriesAlias)){
742
- if (value !== entry) {
743
- reversedAlias[value] = key;
744
- }
745
- }
746
743
  const hasNoExternal = options.external === null;
747
744
  var _options_external;
748
745
  const externals = hasNoExternal ? [] : [
@@ -750,7 +747,8 @@ async function buildInputConfig(entry, entries, pkg, options, cwd, { tsConfigPat
750
747
  pkg.dependencies,
751
748
  pkg.peerDependenciesMeta
752
749
  ].filter((n)=>Boolean(n)).map((o)=>Object.keys(o)).reduce((a, b)=>a.concat(b), []).concat((_options_external = options.external) != null ? _options_external : []);
753
- for (const [exportImportPath, entryFilePath] of Object.entries(entriesAlias)){
750
+ for (const [exportImportPath, exportCondition] of Object.entries(entries)){
751
+ const entryFilePath = exportCondition.source;
754
752
  if (entryFilePath !== entry) {
755
753
  externals.push(exportImportPath);
756
754
  externals.push(entryFilePath);
@@ -787,7 +785,11 @@ async function buildInputConfig(entry, entries, pkg, options, cwd, { tsConfigPat
787
785
  const commonPlugins = [
788
786
  sizePlugin,
789
787
  aliasEntries({
790
- entries: reversedAlias
788
+ entries: {
789
+ ...pluginContext.entriesAlias,
790
+ // Do not alias current alias of package
791
+ [entry]: null
792
+ }
791
793
  })
792
794
  ];
793
795
  const typesPlugins = [
@@ -1340,9 +1342,11 @@ async function bundle(entryPath, { cwd: _cwd, ...options } = {}) {
1340
1342
  const sizeCollector = createChunkSizeCollector({
1341
1343
  entries
1342
1344
  });
1345
+ const entriesAlias = getReversedAlias(entries);
1343
1346
  const pluginContext = {
1344
1347
  sizeCollector,
1345
- moduleDirectiveLayerMap: new Map()
1348
+ moduleDirectiveLayerMap: new Map(),
1349
+ entriesAlias
1346
1350
  };
1347
1351
  const buildConfigs = await buildEntryConfig(entries, pkg, exportPaths, options, cwd, defaultTsOptions, pluginContext, false);
1348
1352
  const assetsJobs = buildConfigs.map((rollupConfig)=>bundleOrWatch(rollupConfig));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "4.2.10",
3
+ "version": "4.2.11",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": "./dist/bin/cli.js",
6
6
  "main": "./dist/index.js",