Skip to content

Commit

Permalink
fix: hydrate entry file path
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Mar 11, 2024
1 parent c3f0235 commit 409ef4e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .changeset/ninety-trains-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@marko/translator-default": patch
"@marko/translator-tags": patch
"@marko/compiler": patch
"marko": patch
"@marko/translator-interop-class-tags": patch
---

Fix regression where hydrate entry files had incorrect relative paths.
9 changes: 8 additions & 1 deletion packages/translator-default/src/util/add-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ export default (entryFile, isHydrate) => {
visitedFiles.add(resolved);
const file = loadFileForImport(entryFile, resolved);
if (file) {
entryBuilder.visit(file, entryFile, visitChild);
entryBuilder.visit(file, entryFile, (id) =>
visitChild(
resolveRelativePath(
entryFile,
path.join(file.opts.filename, "..", id),
),
),
);
}
}
});
Expand Down
9 changes: 8 additions & 1 deletion packages/translator-interop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,14 @@ function patchTranslateProgram(visitor: t.Visitor) {
visitedFiles.add(resolved);
const file = loadFileForImport(entryFile, resolved);
if (file) {
entryBuilder.visit(file, entryFile, visitChild);
entryBuilder.visit(file, entryFile, (id) =>
visitChild(
resolveRelativePath(
entryFile,
path.join(file.opts.filename as string, "..", id),
),
),
);
}
}
});
Expand Down
10 changes: 9 additions & 1 deletion packages/translator-tags/src/visitors/program/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "path";
import { loadFileForImport, resolveRelativePath } from "@marko/babel-utils";
import { types as t } from "@marko/compiler";
import entryBuilder from "../../util/entry-builder";
Expand Down Expand Up @@ -65,7 +66,14 @@ export default {
visitedFiles.add(resolved);
const file = loadFileForImport(entryFile, resolved);
if (file) {
entryBuilder.visit(file, entryFile, visitChild);
entryBuilder.visit(file, entryFile, (id) =>
visitChild(
resolveRelativePath(
entryFile,
path.join(file.opts.filename as string, "..", id),
),
),
);
}
}
});
Expand Down

0 comments on commit 409ef4e

Please sign in to comment.