diff --git a/packages/remix-dev/cli/commands.ts b/packages/remix-dev/cli/commands.ts index 0540953ddb1..0363b2d6e2d 100644 --- a/packages/remix-dev/cli/commands.ts +++ b/packages/remix-dev/cli/commands.ts @@ -22,6 +22,7 @@ import { log } from "../logging"; import { createApp } from "./create"; import { getPreferredPackageManager } from "./getPreferredPackageManager"; import { setupRemix, isSetupPlatform, SetupPlatform } from "./setup"; +import { convertTSFileToJS } from "./migrate/migrations/convert-to-javascript/convertTSFilesToJS/convertTSFileToJS"; export * as migrate from "./migrate"; @@ -398,12 +399,24 @@ export async function generateEntry(remixRoot: string, entry: string) { return; } - // 3. copy the entry file from the template + let inputFile = entry.startsWith("entry.client.") + ? defaultEntryClient + : defaultEntryServer; let outputFile = path.resolve(remixRoot, entry); - await fse.copyFile( - entry.startsWith("entry.client.") ? defaultEntryClient : defaultEntryServer, - outputFile - ); + + // 3. if entry is jsx?, convert to js + // otherwise, copy the entry file from the defaults + if (/\.jsx?$/.test(entry)) { + let contents = await fse.readFile(inputFile, "utf-8"); + let javascript = convertTSFileToJS({ + filename: entry, + projectDir: remixRoot, + source: contents, + }); + await fse.writeFile(outputFile, javascript); + } else { + await fse.copyFile(inputFile, outputFile); + } console.log(colors.blue(`Entry file ${entry} created at ${outputFile}.`)); }