bunchee 6.9.1 → 6.9.3
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 +17 -6
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -856,7 +856,7 @@ async function lint$1(cwd) {
|
|
|
856
856
|
}
|
|
857
857
|
}
|
|
858
858
|
|
|
859
|
-
var version = "6.9.
|
|
859
|
+
var version = "6.9.3";
|
|
860
860
|
|
|
861
861
|
async function writeDefaultTsconfig(tsConfigPath) {
|
|
862
862
|
await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
|
|
@@ -1046,10 +1046,14 @@ function createExportCondition(exportName, sourceFile, moduleType, esmOnly = fal
|
|
|
1046
1046
|
if (exportName === '.') {
|
|
1047
1047
|
exportName = 'index';
|
|
1048
1048
|
}
|
|
1049
|
+
const outputPathPrefix = esmOnly ? '' : 'es';
|
|
1049
1050
|
if (isTsSourceFile) {
|
|
1050
|
-
const importCondition = {
|
|
1051
|
-
types: getDistPath(
|
|
1052
|
-
default: getDistPath(
|
|
1051
|
+
const importCondition = esmOnly ? {
|
|
1052
|
+
types: getDistPath(outputPathPrefix, `${exportName}.${dtsExtensionsMap[esmExtension]}`),
|
|
1053
|
+
default: getDistPath(`${exportName}.${esmExtension}`)
|
|
1054
|
+
} : {
|
|
1055
|
+
types: getDistPath(outputPathPrefix, `${exportName}.${dtsExtensionsMap[esmExtension]}`),
|
|
1056
|
+
default: getDistPath(outputPathPrefix, `${exportName}.${esmExtension}`)
|
|
1053
1057
|
};
|
|
1054
1058
|
if (esmOnly) {
|
|
1055
1059
|
return importCondition;
|
|
@@ -1081,8 +1085,9 @@ function createExportConditionPair(exportName, sourceFile, moduleType, esmOnly =
|
|
|
1081
1085
|
// ./index.develop -> index
|
|
1082
1086
|
// ./foo.react-server -> foo
|
|
1083
1087
|
const fileBaseName = exportName.split('.').slice(0, 2).join('.').replace('./', '');
|
|
1088
|
+
const fileName = `${fileBaseName}-${specialConditionName}.mjs`;
|
|
1084
1089
|
specialCondition = {
|
|
1085
|
-
[specialConditionName]: getDistPath('es',
|
|
1090
|
+
[specialConditionName]: getDistPath(esmOnly ? '' : 'es', fileName)
|
|
1086
1091
|
};
|
|
1087
1092
|
return [
|
|
1088
1093
|
normalizedExportPath,
|
|
@@ -1221,7 +1226,6 @@ async function prepare(cwd, options) {
|
|
|
1221
1226
|
if (esmOnly) {
|
|
1222
1227
|
// When esmOnly is true, mainExport is either a string or an object with types/default
|
|
1223
1228
|
pkgJson.main = isUsingTs ? typeof mainExport === 'object' ? mainExport.default : mainExport : typeof mainExport === 'string' ? mainExport : mainExport.default;
|
|
1224
|
-
pkgJson.module = isUsingTs ? typeof mainExport === 'object' ? mainExport.default : mainExport : typeof mainExport === 'string' ? mainExport : mainExport.default;
|
|
1225
1229
|
if (isUsingTs && typeof mainExport === 'object') {
|
|
1226
1230
|
pkgJson.types = mainExport.types;
|
|
1227
1231
|
}
|
|
@@ -1255,6 +1259,13 @@ async function prepare(cwd, options) {
|
|
|
1255
1259
|
if (options == null ? void 0 : options.esm) {
|
|
1256
1260
|
addBuildScripts(pkgJson, cwd);
|
|
1257
1261
|
}
|
|
1262
|
+
// Add bunchee to devDependencies if not already present
|
|
1263
|
+
if (!pkgJson.devDependencies) {
|
|
1264
|
+
pkgJson.devDependencies = {};
|
|
1265
|
+
}
|
|
1266
|
+
if (!pkgJson.devDependencies.bunchee) {
|
|
1267
|
+
pkgJson.devDependencies.bunchee = 'latest';
|
|
1268
|
+
}
|
|
1258
1269
|
await fsp__default.default.writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
|
|
1259
1270
|
logger.info('Configured `exports` in package.json');
|
|
1260
1271
|
}
|