Skip to content

Commit

Permalink
feat(init): add choose bundler prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak committed Jan 18, 2025
1 parent 5551cca commit fdbd656
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/init/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const argv = yargs(hideBin(process.argv))
type: 'string',
choices: ['rspack', 'webpack'],
description: 'Specify the bundler to use',
default: 'rspack',
})
.option('custom-version', {
alias: 'c',
Expand Down
24 changes: 24 additions & 0 deletions packages/init/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { select } from '@inquirer/prompts';
import addDependencies from './tasks/addDependencies.js';
import checkPackageManager from './tasks/checkPackageManager.js';
import checkReactNative from './tasks/checkReactNative.js';
Expand Down Expand Up @@ -33,6 +34,29 @@ export default async function run({

checkReactNative(cwd);

if (!bundler) {
const isCI = process.env.CI === 'true';
if (isCI) {
bundler = 'rspack';
logger.info('Running in CI, using rspack');
} else {
bundler = await select({
message: 'Which bundler would you like to use?',
choices: [
{
name: 'Rspack (recommended)',
value: 'rspack',
},
{
name: 'Webpack',
value: 'webpack',
}
],
default: 'rspack'
});
}
}

await addDependencies(bundler, cwd, packageManager, repackVersion);

await createBundlerConfig(bundler, cwd, templateType, entry);
Expand Down

0 comments on commit fdbd656

Please sign in to comment.