fix: client script source map returning 404 (#2071)
This commit is contained in:
@@ -195,9 +195,15 @@ export class ServerContext {
|
||||
});
|
||||
|
||||
return response;
|
||||
} else if (url.pathname === DEV_CLIENT_URL) {
|
||||
} else if (
|
||||
url.pathname === DEV_CLIENT_URL ||
|
||||
url.pathname === `${DEV_CLIENT_URL}.map`
|
||||
) {
|
||||
const bundlePath = (url.pathname.endsWith(".map"))
|
||||
? "fresh_dev_client.js.map"
|
||||
: "fresh_dev_client.js";
|
||||
return bundleAssetRoute(req, { ...connInfo, isPartial: false }, {
|
||||
path: "client.js",
|
||||
path: bundlePath,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -635,7 +641,7 @@ function collectEntrypoints(
|
||||
? import.meta.resolve(`${entrypointBase}/main_dev.ts`)
|
||||
: import.meta.resolve(`${entrypointBase}/main.ts`),
|
||||
deserializer: import.meta.resolve(`${entrypointBase}/deserializer.ts`),
|
||||
client: import.meta.resolve(`${entrypointBase}/client.ts`),
|
||||
fresh_dev_client: import.meta.resolve(`${entrypointBase}/client.ts`),
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertEquals, assertStringIncludes } from "./deps.ts";
|
||||
import { assert, assertEquals, assertStringIncludes } from "./deps.ts";
|
||||
import { Status } from "../server.ts";
|
||||
import {
|
||||
assertNotSelector,
|
||||
@@ -146,3 +146,21 @@ Deno.test("show codeframe in dev mode even with custom 500", async () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("serve client script source map", async () => {
|
||||
await withFakeServe(
|
||||
"./tests/fixture/dev.ts",
|
||||
async (server) => {
|
||||
const res = await server.get(`/_frsh/fresh_dev_client.js`);
|
||||
await res.text(); // Consume body
|
||||
assertEquals(res.status, 200);
|
||||
assertEquals(res.headers.get("Content-Type"), "application/javascript");
|
||||
|
||||
const res2 = await server.get(`/_frsh/fresh_dev_client.js.map`);
|
||||
const json = await res2.json();
|
||||
assertEquals(res2.status, 200);
|
||||
assertEquals(res2.headers.get("Content-Type"), "application/json");
|
||||
assert(typeof json.mappings, "string");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user