Skip to content

Commit 59efec6

Browse files
committed
chore: esm framework will be set by default if Flow or React exists
1 parent 227d892 commit 59efec6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class CreateJavascriptProject extends Command {
2828
await checkPackageJson();
2929
const answers = await collectAnswers();
3030

31+
if (answers.configurations.includes("flow") || answers.framework !== "none") {
32+
answers.module = "esm";
33+
}
34+
3135
const formatterFactory = FormatterFactory.getInstance();
3236
const formatter = formatterFactory.createFormatter(answers.format);
3337

src/inquirer.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { prompt } from "inquirer";
2-
import { GeneratorType, InquirerConfigs, Module } from "./types";
2+
import { GeneratorType, InquirerConfigs } from "./types";
33

44
export async function collectAnswers(): Promise<InquirerConfigs> {
55
const answers = await prompt<InquirerConfigs>([
@@ -53,11 +53,6 @@ export async function collectAnswers(): Promise<InquirerConfigs> {
5353
{ name: "CommonJS (require/exports)", value: "commonjs" },
5454
],
5555
when: (answers) => !answers.configurations.includes("flow") && answers.framework === "none",
56-
validate: (input: Module, answers) => {
57-
return input === "commonjs" && answers?.framework === "react"
58-
? "You cannot use React with commonjs"
59-
: true;
60-
},
6156
},
6257
{
6358
type: "confirm",

0 commit comments

Comments
 (0)