Comparing version 4.2.3 to 4.2.4
@@ -118,3 +118,3 @@ #!/usr/bin/env node | ||
var version = "4.2.3"; | ||
var version = "4.2.4"; | ||
@@ -121,0 +121,0 @@ const helpMessage = ` |
@@ -373,9 +373,9 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
} else { | ||
const keys = Object.keys(exportCondition); | ||
const exportTypes = Object.keys(exportCondition); | ||
fullExportCond = {}; | ||
keys.forEach((key)=>{ | ||
const condition = exportCondition[key]; | ||
exportTypes.forEach((exportType)=>{ | ||
const condition = exportCondition[exportType]; | ||
// Filter out nullable value | ||
if (key in exportCondition && condition) { | ||
fullExportCond[key] = condition; | ||
if (condition) { | ||
fullExportCond[exportType] = condition; | ||
} | ||
@@ -388,4 +388,4 @@ }); | ||
let result = path.join(...segments); | ||
// If the first segment starts with './', ensure the result does too. | ||
if (segments[0] === '.' && !result.startsWith('./')) { | ||
// If the first segment starts with '.', ensure the result does too. | ||
if (segments[0] === '.' && !result.startsWith('.')) { | ||
result = './' + result; | ||
@@ -395,12 +395,26 @@ } | ||
} | ||
function findExport(name, exportCondition, paths, packageType) { | ||
// TODO: handle export condition based on package.type | ||
function findExport(exportPath, exportCondition, paths, packageType) { | ||
if (isExportLike(exportCondition)) { | ||
paths[name] = constructFullExportCondition(exportCondition, packageType); | ||
const fullExportCondition = constructFullExportCondition(exportCondition, packageType); | ||
paths[exportPath] = { | ||
...paths[exportPath], | ||
...fullExportCondition | ||
}; | ||
return; | ||
} | ||
Object.keys(exportCondition).forEach((subpath)=>{ | ||
const nextName = joinRelativePath(name, subpath); | ||
const nestedExportCondition = exportCondition[subpath]; | ||
findExport(nextName, nestedExportCondition, paths, packageType); | ||
if (subpath.startsWith('.')) { | ||
// subpath is actual export path, ./a, ./b, ... | ||
const nestedExportPath = joinRelativePath(exportPath, subpath); | ||
const nestedExportCondition = exportCondition[subpath]; | ||
findExport(nestedExportPath, nestedExportCondition, paths, packageType); | ||
} else { | ||
// subpath is exportType, import, require, ... | ||
const exportType = subpath; | ||
const defaultPath = exportCondition[subpath].default; | ||
const nestedExportCondition = { | ||
[exportType]: defaultPath | ||
}; | ||
findExport(exportPath, nestedExportCondition, paths, packageType); | ||
} | ||
}); | ||
@@ -415,7 +429,6 @@ } | ||
* { | ||
* ".": { | ||
* "sub": { | ||
* "import": "./sub.js", | ||
* "require": "./sub.cjs", | ||
* "types": "./sub.d.ts | ||
* "./sub": { | ||
* "import": { | ||
* "types": "./sub.js", | ||
* "default": "./sub.cjs", | ||
* } | ||
@@ -430,3 +443,3 @@ * } | ||
* "require": "./sub.cjs", | ||
* "types": "./sub.d.ts, | ||
* "types": "./sub.d.ts", | ||
* } | ||
@@ -579,4 +592,3 @@ * } | ||
'main', | ||
'node', | ||
'default' | ||
'node' | ||
].includes(name) && ext !== 'mjs' || ext === 'cjs'; | ||
@@ -612,3 +624,2 @@ } | ||
if (dist.length === 0 && !pkg.bin) { | ||
console.error(`Doesn't fin any exports in ${pkg.name}, using default dist path dist/index.js`); | ||
const defaultFormat = isESModulePackage(pkg.type) ? 'esm' : 'cjs'; | ||
@@ -615,0 +626,0 @@ dist.push({ |
{ | ||
"name": "bunchee", | ||
"version": "4.2.3", | ||
"version": "4.2.4", | ||
"description": "zero config bundler for js/ts/jsx libraries", | ||
@@ -5,0 +5,0 @@ "bin": "./dist/bin/cli.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76804
1634