Skip to content
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

RSC: Patch vite when running setup command #9192

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/cli/src/commands/experimental/setupRscHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs'
import path from 'path'

import execa from 'execa'
import { Listr } from 'listr2'

import { getConfig, getConfigPath } from '@redwoodjs/project-config'
Expand Down Expand Up @@ -184,6 +185,46 @@ export const handler = async ({ force, verbose }) => {
})
},
},
{
title: 'Patch vite',
task: async () => {
const vitePatchTemplate = fs.readFileSync(
path.resolve(
__dirname,
'templates',
'rsc',
'vite-npm-4.4.9-e845c1bbf8.patch.template'
),
'utf-8'
)

const yarnPatchDir = path.join(rwPaths.base, '.yarn', 'patches')
const vitePatchPath = path.join(
yarnPatchDir,
'vite-npm-4.4.9-e845c1bbf8.patch'
)
writeFile(vitePatchPath, vitePatchTemplate, {
overwriteExisting: force,
})

const packageJsonPath = path.join(rwPaths.base, 'package.json')
const packageJson = JSON.parse(
fs.readFileSync(packageJsonPath, 'utf-8')
)
packageJson.resolutions = packageJson.resolutions || {}
packageJson.resolutions['vite@4.4.9'] =
'patch:vite@npm%3A4.4.9#./.yarn/patches/vite-npm-4.4.9-e845c1bbf8.patch'
writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), {
overwriteExisting: true,
})

await execa('yarn install', {
stdio: 'ignore',
shell: true,
cwd: rwPaths.base,
})
},
},
{
task: () => {
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/dist/node/chunks/dep-df561101.js b/dist/node/chunks/dep-df561101.js
index 1bc8674177fe73120171b22436e6104713c5d764..f0fee7b385868cb01c6d47b80d7f64a7368c0412 100644
--- a/dist/node/chunks/dep-df561101.js
+++ b/dist/node/chunks/dep-df561101.js
@@ -55890,12 +55890,12 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
};
urlStack = urlStack.concat(url);
const isCircular = (url) => urlStack.includes(url);
- const { isProduction, resolve: { dedupe, preserveSymlinks }, root, } = server.config;
+ const { isProduction, resolve: { dedupe, preserveSymlinks, conditions }, root, } = server.config;
const resolveOptions = {
mainFields: ['main'],
browserField: true,
conditions: [],
- overrideConditions: ['production', 'development'],
+ overrideConditions: [...conditions, 'production', 'development'],
extensions: ['.js', '.cjs', '.json'],
dedupe,
preserveSymlinks,
Loading