[remix] Install @vercel/remix-run-dev at build-time instead of using symlink (#9784)

Instead of including the fork `@remix-run/dev` package as a regular dependency of `@vercel/remix-builder`, install it at build-time by modifying the project's `package.json` file. The reasons for this are:

* Avoids deprecation warnings from a few packages that currently exist on the `@remix-run/dev` package when installing Vercel CLI (those warnings already show up in the build logs anyways, so nothing new there).
* Allows us to install a version as close as possible to the version specified in the user's `package.json` (similar to how we do when auto-injecting the `@vercel/remix` package). This will be especially important once Remix v2 is released, which will have breaking changes compared to v1.

**Note:** `@vercel/remix-run-dev` is still a _dev_ dependency, so that we can use TypeScript types from it, as well as, at runtime, we use the version in the Builder's `package.json` to determine the maximum versions of `@vercel/remix-run-dev` and/or `@vercel/remix` which can safely be installed.

Fixes #10027.
Fixes #10222.
This commit is contained in:
Nathan Rajlich
2023-07-28 13:49:32 -07:00
committed by GitHub
parent d614709308
commit d1b0dbe3a7
12 changed files with 4474 additions and 3219 deletions

View File

@@ -11,14 +11,13 @@ module.exports = async ({ github, context }, newVersion) => {
const packagePath = path.join(repoRootPath, 'packages', 'remix');
const oldVersion = JSON.parse(
fs.readFileSync(path.join(packagePath, 'package.json'), 'utf-8')
).dependencies['@remix-run/dev'];
).devDependencies['@remix-run/dev'];
if (newVersion === '') {
newVersion = execSync('npm view @vercel/remix-run-dev dist-tags.latest', {
encoding: 'utf-8',
});
}
newVersion = newVersion.trim();
const branch = `vercel-remix-run-dev-${newVersion.replaceAll('.', '-')}`;
if (oldVersion === newVersion) {
// eslint-disable-next-line no-console
@@ -28,6 +27,7 @@ module.exports = async ({ github, context }, newVersion) => {
return;
}
const branch = `vercel-remix-run-dev-${newVersion.replaceAll('.', '-')}`;
if (
execSync(`git ls-remote --heads origin ${branch}`, { encoding: 'utf-8' })
.toString()
@@ -39,7 +39,7 @@ module.exports = async ({ github, context }, newVersion) => {
}
execSync(
`pnpm install @remix-run/dev@npm:@vercel/remix-run-dev@${newVersion} --save-exact --lockfile-only`,
`pnpm install @remix-run/dev@npm:@vercel/remix-run-dev@${newVersion} --save-exact --save-dev --lockfile-only`,
{ cwd: packagePath }
);