Skip to content

Normalize dirent entry path across node versions when generating SRI manifest #13591

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

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
5 changes: 5 additions & 0 deletions .changeset/odd-hounds-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-router/dev": patch
---

[UNSTABLE] Normalize dirent entry path across node versions when generating SRI manifest
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
- parveen232
- paulsmithkc
- pavsoldatov
- pawelblaszczyk5
- pcattori
- penx
- petersendidit
Expand Down
9 changes: 7 additions & 2 deletions packages/react-router-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,15 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
let sriManifest: ReactRouterManifest["sri"] = {};
for (const entry of entries) {
if (entry.isFile() && entry.name.endsWith(".js")) {
const entryNormalizedPath =
"parentPath" in entry && typeof entry.parentPath === "string"
? entry.parentPath
: entry.path;

let contents;
try {
contents = await fse.readFile(
path.join(entry.path, entry.name),
path.join(entryNormalizedPath, entry.name),
"utf-8"
);
} catch (e) {
Expand All @@ -825,7 +830,7 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
.digest()
.toString("base64");
let filepath = getVite().normalizePath(
path.relative(clientBuildDirectory, path.join(entry.path, entry.name))
path.relative(clientBuildDirectory, path.join(entryNormalizedPath, entry.name))
);
sriManifest[`${ctx.publicPath}${filepath}`] = `sha384-${hash}`;
}
Expand Down
Loading