-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(remix-dev): relativize route modules to make builds deterministic #2027
Conversation
7eb108f
to
0737ce8
Compare
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.
I'm surprised that test case fails without your changes (I'm assuming you ran the test first to ensure it does fail without your changes). This is beyond where I'm comfortable merging personally, but I did leave a bit of feedback if you'd like :) Thanks!
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.
Thanks for doing that!
I'll leave the rest of the review to @mjackson
Seems like an unrelated CLI test failed, is there a way to retrigger? Or does it not matter? |
7de6767
to
7a2188d
Compare
@mjackson let me know if you have any questions/suggestions 😄 |
Let's fix the conflicts and then merge this bugger. |
Jon has local changes but Yarn PnP doesn't play nicely with relative paths, so going to wait for a fix there before we do this. |
Alright, I opened a PR to fix the esbuild-plugin-pnp bug, but if we're comfortable shipping this hack we don't technically need to wait for it 😅 |
The esbuild-plugin-pnp bugfix has been merged, so once they release a new version I'll unwind my hack and bump the dependency 🥳 |
3fa2a7d
to
99a79d2
Compare
This PR should be good to go, but it looks like something is generally broken around the caching done by |
getting a weird GH actions failure around the yarn cache on this PR: remix-run#2027 seeing if i can repro with another commit
v1.8.16 breaks cache miss installs on windows, which blocks any PRs/commits that change dependencies. Opened bahmutov/npm-install#146 to address the underlying issue, but in the meantime we can pin to the prior version to get things working again. Additional context: - Discord: https://discord.com/channels/770287896669978684/940264701785423992/991085961972707338 - Initial PR affected: remix-run#2027 - Repro/Debug PR: remix-run#3584
v1.8.16 breaks cache miss installs on windows, which blocks any PRs/commits that change dependencies. Opened bahmutov/npm-install#146 to address the underlying issue, but in the meantime we can pin to the prior version to get things working again. Additional context: - Discord: https://discord.com/channels/770287896669978684/940264701785423992/991085961972707338 - Initial PR affected: remix-run#2027 - Repro/Debug PR: remix-run#3584
v1.8.16 breaks cache miss installs on windows, which blocks any PRs/commits that change dependencies. Opened bahmutov/npm-install#146 to address the underlying issue, but in the meantime we can pin to the prior version to get things working again. Additional context: - Discord: https://discord.com/channels/770287896669978684/940264701785423992/991085961972707338 - Initial PR affected: remix-run#2027 - Repro/Debug PR: remix-run#3584
v1.8.16 breaks cache miss installs on windows, which blocks any PRs/commits that change dependencies. Opened bahmutov/npm-install#146 to address the underlying issue, but in the meantime we can pin to the prior version to get things working again. Additional context: - Discord: https://discord.com/channels/770287896669978684/940264701785423992/991085961972707338 - Initial PR affected: remix-run#2027 - Repro/Debug PR: remix-run#3584
Alright, the PR now uses
That said, this all may be moot as I just noticed this PR which swaps out this plugin entirely 😆😭 ... in any event, here's the diff from 2.0.2 (what people would have been installing prior to this PR). Although the version we're using is an RC, IMO it's safe to use since the only change it brings is my bugfix: diff --git a/packages/esbuild-plugin-pnp/package.json b/packages/esbuild-plugin-pnp/package.json
index dbb346c74..8f22e8fb6 100644
--- a/packages/esbuild-plugin-pnp/package.json
+++ b/packages/esbuild-plugin-pnp/package.json
@@ -1,6 +1,6 @@
{
"name": "@yarnpkg/esbuild-plugin-pnp",
- "version": "2.0.2",
+ "version": "3.0.0-rc.10",
"license": "BSD-2-Clause",
"main": "./sources/index.ts",
"dependencies": {
@@ -31,6 +31,7 @@
"directory": "packages/esbuild-plugin-pnp"
},
"engines": {
- "node": ">=12 <14 || 14.2 - 14.9 || >14.10.0"
- }
+ "node": ">=14.15.0"
+ },
+ "stableVersion": "2.0.1"
}
diff --git a/packages/esbuild-plugin-pnp/sources/index.ts b/packages/esbuild-plugin-pnp/sources/index.ts
index 379b64959..64fff1588 100644
--- a/packages/esbuild-plugin-pnp/sources/index.ts
+++ b/packages/esbuild-plugin-pnp/sources/index.ts
@@ -139,9 +139,11 @@ export function pnpPlugin({
conditions = conditionsRequire;
// The entry point resolution uses an empty string
- const effectiveImporter = args.importer
- ? args.importer
- : `${baseDir}/`;
+ const effectiveImporter = args.resolveDir
+ ? `${args.resolveDir}/`
+ : args.importer
+ ? args.importer
+ : `${baseDir}/`;
const pnpApi = findPnpApi(effectiveImporter) as PnpApi | null;
if (!pnpApi) |
As mentioned in #3594 (comment), I personally would be in favor of solving the problems from #3594 in @jenseng Maybe you could point @lensbart into the right direction for a fix in |
🦋 Changeset detectedLatest commit: 1c6f49e The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Fixes remix-run#2024 If virtual modules have non-deterministic paths or content (e.g. due to importing from other absolute paths), the input is technically different, and deterministic build output is not guaranteed. Depending on how you build/deploy (e.g. if you need to build and deploy your server separately from your browser build), this can result in a broken app, since the server and browser manifests may differ (i.e. due to different fingerprints). By using relative paths for route modules, we can ensure the same result no matter the absolute path. Possibly worth pointing out that this fix also affects file path comments in the server build, e.g. you'll now see stuff like: // app/root.tsx instead of: // /absolute/path/on/the/build/machine/to/app/root.tsx Testing notes: 1. Added integration test 2. Verified manually, i.e. 1. Create two remix projects (via npx create-remix@latest) 2. `npm run build` them both 3. `diff -r project1/build project2/build` has no differences 4. `diff -r project1/public/build project2/public/build` has no differences 5. `dev` and `start` still work as per usual
This is a fix along the lines of remix-run#2027; because the MDX virtual modules resolve to absolute paths, the manifest/hashes/etc. differ based on the parent directory structure. Testing notes: 1. Expanded existing integration test to cover this scenario (fails without the fix). Also add other virtual module scenarios that weren't already covered 2. Validated in a real MDX Remix app that has split client / server builds (applied fix via patch-package)
This is a fix along the lines of remix-run#2027; because the MDX virtual modules resolve to absolute paths, the manifest/hashes/etc. differ based on the parent directory structure. Testing notes: 1. Expanded existing integration test to cover this scenario (fails without the fix). Also add other virtual module scenarios that weren't already covered 2. Validated in a real MDX Remix app that has split client / server builds (applied fix via patch-package)
Closes #2024
This fixes an issue where the build manifest/hashes/etc will differ based on the parent directory structure. If virtual modules import from absolute paths, their content is technically different when those paths change, so deterministic build output is not guaranteed.
Depending on how you build/deploy (e.g. if you need to build and deploy your server separately from your browser build), this can result in a broken app, since the server and browser manifests may differ (i.e. due to different fingerprints). Sometimes you can't directly control the absolute path where you code is checked out and run (e.g. Jenkins, docker, etc.).
By using relative paths for route modules, we can ensure the same result no matter the absolute path.
Possibly worth pointing out that this fix also affects file path comments in the server build, e.g. you'll now see stuff like:
// app/root.tsx
instead of:
// /absolute/path/on/the/build/machine/to/app/root.tsx
Testing notes:
npm run build
them bothdiff -r project1/build project2/build
has no differencesdiff -r project1/public/build project2/public/build
has no differencesdev
andstart
still work as per usual