-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(remix-dev): relativize route modules to make builds deterministic
Fixes #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
- Loading branch information
Showing
6 changed files
with
49 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import globby from "globby"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
import { createFixtureProject } from "./helpers/create-fixture"; | ||
|
||
test("builds deterministically under different paths", async () => { | ||
let dir1 = await createFixtureProject(); | ||
let dir2 = await createFixtureProject(); | ||
|
||
expect(dir1).not.toEqual(dir2); | ||
|
||
let files1 = await globby(["build/index.js", "public/build/**/*.js"], { | ||
cwd: dir1, | ||
}); | ||
let files2 = await globby(["build/index.js", "public/build/**/*.js"], { | ||
cwd: dir2, | ||
}); | ||
|
||
expect(files1.length).toBeGreaterThan(0); | ||
expect(files1).toEqual(files2); | ||
files1.forEach((file, i) => { | ||
expect(fs.readFileSync(path.join(dir1, file))).toEqual( | ||
fs.readFileSync(path.join(dir2, files2[i])) | ||
); | ||
}); | ||
}); |
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
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
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
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
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