-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSC: Patch vite when running setup command (#9192)
This is needed until vitejs/vite#13487 is merged and released and RW uses that new version of Vite
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
@@ -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['[email protected]'] = | ||
'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) | ||
|
19 changes: 19 additions & 0 deletions
19
...ages/cli/src/commands/experimental/templates/rsc/vite-npm-4.4.9-e845c1bbf8.patch.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |