-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(remix): Add Vite support. #495
Changes from 1 commit
9bd9874
177ab2b
a184b9f
25b2e75
6c2e811
8ee9afa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import type { ProxifiedModule } from 'magicast'; | |
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as url from 'url'; | ||
import * as childProcess from 'child_process'; | ||
|
||
// @ts-expect-error - clack is ESM and TS complains about that. It works though | ||
import clack from '@clack/prompts'; | ||
|
@@ -22,6 +23,7 @@ import { instrumentRootRouteV1 } from './codemods/root-v1'; | |
import { instrumentRootRouteV2 } from './codemods/root-v2'; | ||
import { instrumentHandleError } from './codemods/handle-error'; | ||
import { getPackageDotJson } from '../utils/clack-utils'; | ||
import { configureVitePlugin } from '../sourcemaps/tools/vite'; | ||
|
||
export type PartialRemixConfig = { | ||
unstable_dev?: boolean; | ||
|
@@ -36,6 +38,52 @@ export type PartialRemixConfig = { | |
}; | ||
|
||
const REMIX_CONFIG_FILE = 'remix.config.js'; | ||
const REMIX_REVEAL_COMMAND = 'npx remix reveal'; | ||
|
||
export function runRemixReveal(isTS: boolean): void { | ||
// Check if entry files already exist | ||
const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`; | ||
const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`; | ||
|
||
const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename); | ||
const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename); | ||
|
||
if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) { | ||
clack.log.info( | ||
`Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan( | ||
serverEntryFilename, | ||
)}.`, | ||
); | ||
} else { | ||
clack.log.info( | ||
`Couldn't find entry files in your project. Trying to run ${chalk.cyan( | ||
REMIX_REVEAL_COMMAND, | ||
)}...`, | ||
); | ||
|
||
childProcess.execSync(REMIX_REVEAL_COMMAND, { | ||
stdio: 'inherit', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is handled on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh right, I missed this, thanks! |
||
}); | ||
} | ||
} | ||
|
||
export async function modifyViteConfig( | ||
selectedProject: { | ||
organization: { slug: string }; | ||
slug: string; | ||
}, | ||
sentryUrl: string, | ||
authToken: string, | ||
selfHosted: boolean, | ||
): Promise<void> { | ||
await configureVitePlugin({ | ||
orgSlug: selectedProject.organization.slug, | ||
projectSlug: selectedProject.slug, | ||
url: sentryUrl, | ||
selfHosted, | ||
authToken, | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: Can we just directly call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, makes sense 👍 updated -> 177ab2b |
||
|
||
function insertClientInitCall( | ||
dsn: string, | ||
|
@@ -192,6 +240,10 @@ export async function updateBuildScript(args: { | |
buildCommand, | ||
instrumentedBuildCommand, | ||
); | ||
} else { | ||
throw new Error( | ||
"`build` script doesn't contain a known build command. Please update it manually.", | ||
); | ||
} | ||
|
||
await fs.promises.writeFile( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Can we pipe the output from the command and wrap it in a
clack
call? Currently this somewhat breaks the UI:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 👍 -> a184b9f