diff --git a/src/cli-main.ts b/src/cli-main.ts index 1c40dac1..21944395 100644 --- a/src/cli-main.ts +++ b/src/cli-main.ts @@ -16,6 +16,7 @@ export async function main(options: Options = {}) { .command('[...files]', 'Bundle files', { ignoreOptionDefaultValue: true, }) + .option('--entry.* ', 'Use a key-value pair as entry files') .option('-d, --out-dir ', 'Output directory', { default: 'dist' }) .option('--format ', 'Bundle format, "cjs", "iife", "esm"', { default: 'cjs', @@ -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) { diff --git a/test/index.test.ts b/test/index.test.ts index 77acc078..cf12a64e 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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", + ] + `) +})