bunchee 6.4.0 → 6.5.1

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
@@ -646,7 +646,7 @@ function lint$1(pkg) {
646
646
  }
647
647
  }
648
648
 
649
- var version = "6.4.0";
649
+ var version = "6.5.1";
650
650
 
651
651
  async function writeDefaultTsconfig(tsConfigPath) {
652
652
  await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
@@ -973,14 +973,17 @@ async function prepare(cwd) {
973
973
  } else {
974
974
  // Update existing exports
975
975
  Object.keys(pkgExports).forEach((exportName)=>{
976
- if (pkgJson.exports[exportName]) {
977
- pkgJson.exports[exportName] = pkgExports[exportName];
978
- }
976
+ pkgJson.exports[exportName] = {
977
+ // Apply the new export conditions
978
+ ...pkgJson.exports[exportName],
979
+ // Keep the existing export conditions
980
+ ...pkgJson.exports[exportName]
981
+ };
979
982
  });
980
983
  }
981
984
  }
982
985
  }
983
- await fsp__default.default.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
986
+ await fsp__default.default.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
984
987
  logger.info('Configured `exports` in package.json');
985
988
  }
986
989
 
package/dist/index.d.ts CHANGED
@@ -47,4 +47,5 @@ type BrowserslistConfig = string | string[] | Record<string, string>;
47
47
 
48
48
  declare function bundle(cliEntryPath: string, { cwd: _cwd, onSuccess, ...options }?: BundleConfig): Promise<void>;
49
49
 
50
- export { type BundleConfig, bundle };
50
+ export { bundle };
51
+ export type { BundleConfig };
package/dist/index.js CHANGED
@@ -1507,7 +1507,7 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
1507
1507
  target: jscTarget
1508
1508
  },
1509
1509
  loose: true,
1510
- externalHelpers: false,
1510
+ externalHelpers: true,
1511
1511
  parser: swcParserConfig,
1512
1512
  transform: {
1513
1513
  decoratorVersion: '2022-03'
@@ -1641,6 +1641,10 @@ function createSplitChunks(dependencyGraphMap, entryFiles) {
1641
1641
  // If there's existing chunk being splitted, and contains a layer { <id>: <chunkGroup> }
1642
1642
  const splitChunksGroupMap = new Map();
1643
1643
  return function splitChunks(id, ctx) {
1644
+ if (/[\\/]node_modules[\\/]\@swc[\\/]helper/.test(id)) {
1645
+ return 'cc' // common chunk
1646
+ ;
1647
+ }
1644
1648
  const moduleInfo = ctx.getModuleInfo(id);
1645
1649
  if (!moduleInfo) {
1646
1650
  return;
@@ -1974,9 +1978,11 @@ async function bundle(cliEntryPath, { cwd: _cwd, onSuccess, ...options } = {}) {
1974
1978
  const err = new Error(`Entry file "${cliEntryPath}" does not exist`);
1975
1979
  err.name = 'NOT_EXISTED';
1976
1980
  return Promise.reject(err);
1977
- } else if (cwd) {
1978
- const hasProjectDir = fs__default.default.existsSync(cwd) && (await fsp__default.default.stat(cwd)).isDirectory();
1979
- if (!hasProjectDir) {
1981
+ } else {
1982
+ // Check if the project directory exists
1983
+ const hasProjectDir = cwd && fs__default.default.existsSync(cwd) && (await fsp__default.default.stat(cwd)).isDirectory();
1984
+ // Error if the project directory does not exist
1985
+ if (cwd && !hasProjectDir) {
1980
1986
  const err = new Error(`Project directory "${cwd}" does not exist`);
1981
1987
  err.name = 'NOT_EXISTED';
1982
1988
  return Promise.reject(err);
@@ -1984,6 +1990,13 @@ async function bundle(cliEntryPath, { cwd: _cwd, onSuccess, ...options } = {}) {
1984
1990
  }
1985
1991
  }
1986
1992
  const entries = await collectEntriesFromParsedExports(cwd, parsedExportsInfo, pkg, inputFile);
1993
+ // Collect and log missing entries for defined exports
1994
+ const missingEntries = [
1995
+ ...parsedExportsInfo.keys()
1996
+ ].filter((key)=>!entries[key] && key !== './package.json');
1997
+ if (missingEntries.length > 0) {
1998
+ logger.warn(`The following exports are defined in package.json but missing source files:\n${missingEntries.map((name)=>`⨯ ${name}`).join('\n')}\n`);
1999
+ }
1987
2000
  const hasTypeScriptFiles = Object.values(entries).some((entry)=>isTypescriptFile(entry.source));
1988
2001
  // If there's no tsconfig, create one.
1989
2002
  if (hasTypeScriptFiles && !hasTsConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "6.4.0",
3
+ "version": "6.5.1",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": "./dist/bin/cli.js",
6
6
  "main": "./dist/index.js",
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@rollup/plugin-commonjs": "^28.0.2",
40
+ "@rollup/plugin-commonjs": "^28.0.3",
41
41
  "@rollup/plugin-json": "^6.1.0",
42
- "@rollup/plugin-node-resolve": "^16.0.0",
42
+ "@rollup/plugin-node-resolve": "^16.0.1",
43
43
  "@rollup/plugin-replace": "^6.0.2",
44
44
  "@rollup/plugin-wasm": "^6.2.2",
45
45
  "@rollup/pluginutils": "^5.1.4",
46
- "@swc/core": "^1.10.16",
46
+ "@swc/core": "^1.11.21",
47
47
  "@swc/helpers": "^0.5.15",
48
48
  "clean-css": "^5.3.3",
49
49
  "fast-glob": "^3.3.3",
@@ -51,8 +51,8 @@
51
51
  "ora": "^8.0.1",
52
52
  "picomatch": "^4.0.2",
53
53
  "pretty-bytes": "^5.6.0",
54
- "rollup": "^4.34.7",
55
- "rollup-plugin-dts": "^6.1.1",
54
+ "rollup": "^4.40.0",
55
+ "rollup-plugin-dts": "^6.2.1",
56
56
  "rollup-plugin-swc3": "^0.11.1",
57
57
  "rollup-preserve-directives": "^1.1.3",
58
58
  "tslib": "^2.8.1",