fix: cut off file names when project is at root / (#1957)

This commit is contained in:
Marvin Hagemeister
2023-10-18 18:27:56 +02:00
committed by GitHub
parent 84ff79beca
commit 4c59f9df65
4 changed files with 69 additions and 5 deletions
+4 -5
View File
@@ -5,7 +5,7 @@ import {
esbuildWasmURL,
fromFileUrl,
regexpEscape,
toFileUrl,
relative,
} from "./deps.ts";
import { Builder, BuildSnapshot } from "./mod.ts";
@@ -21,6 +21,7 @@ export interface EsbuildBuilderOptions {
/** The JSX configuration. */
jsxConfig: JSXConfig;
target: string | string[];
absoluteWorkingDir: string;
}
export interface JSXConfig {
@@ -40,7 +41,7 @@ export class EsbuildBuilder implements Builder {
try {
await initEsbuild();
const absWorkingDir = Deno.cwd();
const absWorkingDir = opts.absoluteWorkingDir;
// In dev-mode we skip identifier minification to be able to show proper
// component names in Preact DevTools instead of single characters.
@@ -82,10 +83,8 @@ export class EsbuildBuilder implements Builder {
const files = new Map<string, Uint8Array>();
const dependencies = new Map<string, string[]>();
const absWorkingDirLen = toFileUrl(absWorkingDir).href.length + 1;
for (const file of bundle.outputFiles) {
const path = toFileUrl(file.path).href.slice(absWorkingDirLen);
const path = relative(absWorkingDir, file.path);
files.set(path, file.contents);
}