Skip to content

Commit

Permalink
feat: add console for experimental wildcard
Browse files Browse the repository at this point in the history
Co-authored-by: Jiachi Liu <[email protected]>
  • Loading branch information
devjiwonchoi and huozhi committed Aug 20, 2023
1 parent a3681c6 commit 19139e9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/experimental/wildcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
} from '../utils'

const getWildcardEntry = (
key: string,
key: string | undefined,
exports: Record<string, ExportCondition>,
): Record<string, ExportCondition> | undefined => {
if (!key.includes('./*') || !exports[key]) return undefined
if (!key || !key.includes('./*') || !exports[key]) return undefined
return { [key]: exports[key] }
}

Expand Down Expand Up @@ -77,8 +77,16 @@ export async function validateExports(
exports: ExportCondition | Record<string, ExportCondition>,
cwd: string,
): Promise<ExportCondition> {
if (typeof exports === 'string') return exports
const wildcardEntry = getWildcardEntry('./*', exports)
const wildcardKey = Object.keys(exports).find((key) => key.includes('./*'))
if (typeof exports === 'string' || !wildcardKey) return exports

console.warn(
`The wildcard export "./*" is experimental and may change or be removed at any time.\n` +
'To open an issue, please visit https://github.com/huozhi/bunchee/issues' +
'.\n',
)

const wildcardEntry = getWildcardEntry(wildcardKey, exports)
if (!wildcardEntry) return exports

const exportables = await getExportables(cwd)
Expand Down

0 comments on commit 19139e9

Please sign in to comment.