Skip to content

Commit 728dc96

Browse files
Normalize dirent entry path across node versions when generating SRI manifest (#13591)
1 parent 2fae6d9 commit 728dc96

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.changeset/odd-hounds-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
[UNSTABLE] Normalize dirent entry path across node versions when generating SRI manifest

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
- parveen232
268268
- paulsmithkc
269269
- pavsoldatov
270+
- pawelblaszczyk5
270271
- pcattori
271272
- penx
272273
- petersendidit

packages/react-router-dev/vite/plugin.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,15 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
810810
let sriManifest: ReactRouterManifest["sri"] = {};
811811
for (const entry of entries) {
812812
if (entry.isFile() && entry.name.endsWith(".js")) {
813+
const entryNormalizedPath =
814+
"parentPath" in entry && typeof entry.parentPath === "string"
815+
? entry.parentPath
816+
: entry.path;
817+
813818
let contents;
814819
try {
815820
contents = await fse.readFile(
816-
path.join(entry.path, entry.name),
821+
path.join(entryNormalizedPath, entry.name),
817822
"utf-8"
818823
);
819824
} catch (e) {
@@ -825,7 +830,7 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
825830
.digest()
826831
.toString("base64");
827832
let filepath = getVite().normalizePath(
828-
path.relative(clientBuildDirectory, path.join(entry.path, entry.name))
833+
path.relative(clientBuildDirectory, path.join(entryNormalizedPath, entry.name))
829834
);
830835
sriManifest[`${ctx.publicPath}${filepath}`] = `sha384-${hash}`;
831836
}

0 commit comments

Comments
 (0)