Skip to content

Commit

Permalink
feat: allow to use an object as entry with --entry flag
Browse files Browse the repository at this point in the history
  • Loading branch information
EGOIST committed Jun 5, 2022
1 parent 0a96985 commit 33a7c5f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cli-main.ts
Expand Up @@ -16,6 +16,7 @@ export async function main(options: Options = {}) {
.command('[...files]', 'Bundle files', {
ignoreOptionDefaultValue: true,
})
.option('--entry.* <file>', 'Use a key-value pair as entry files')
.option('-d, --out-dir <dir>', 'Output directory', { default: 'dist' })
.option('--format <format>', 'Bundle format, "cjs", "iife", "esm"', {
default: 'cjs',
Expand Down Expand Up @@ -91,7 +92,7 @@ export async function main(options: Options = {}) {
Object.assign(options, {
...flags,
})
if (files.length > 0) {
if (!options.entry && files.length > 0) {
options.entry = files.map(slash)
}
if (flags.format) {
Expand Down
17 changes: 17 additions & 0 deletions test/index.test.ts
Expand Up @@ -907,3 +907,20 @@ test('custom config file', async () => {
]
`)
})

test('use an object as entry from cli flag', async () => {
const { outFiles } = await run(
getTestName(),
{
'input.ts': `export const foo = [1,2,3]`,
},
{
flags: ['--entry.foo', 'input.ts'],
}
)
expect(outFiles).toMatchInlineSnapshot(`
[
"foo.js",
]
`)
})

0 comments on commit 33a7c5f

Please sign in to comment.