这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,27 @@ const normalizeOptions = async (
}

if (Array.isArray(entry)) {
const matcher = picomatch(entry, { windows: process.platform === 'win32' })
// using a directory as entry should match all files inside it
const expandedEntries = entry.map((pattern) => {
if (!pattern.endsWith('**')) {
return `${pattern}/**`
}
return pattern
})
const matchPatterns: string[] = []
const ignorePatterns: string[] = []
for (const pattern of expandedEntries) {
if (pattern.startsWith('!') && pattern[1] !== '(') {
ignorePatterns.push(pattern.slice(1))
} else {
matchPatterns.push(pattern)
}
}
const matcher = picomatch(matchPatterns, {
ignore: ignorePatterns,
dot: true,
windows: process.platform === 'win32',
})
options.entry = await new fdir()
.withRelativePaths()
.filter((file) => matcher(file))
Expand Down
16 changes: 16 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,3 +901,19 @@ test('generate sourcemap with --treeshake', async () => {
}),
)
})

test('should not throw when having directories as entry', async () => {
const sourceCode = 'export const h = "h"'

expect(
run(
getTestName(),
{
'src/input.ts': sourceCode,
},
{
entry: ['src'],
},
),
).resolves
})