Skip to content

Commit

Permalink
fix: simplify relative path resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jan 2, 2022
1 parent f2a689b commit 31c7172
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"extension": ["js", "ts"],
"enable-source-maps": true,
"watchFiles": ["src/**/*.ts"],
"require": ["./esbuild-register", "mocha-snap"]
"require": ["esbuild-register", "mocha-snap"]
}
1 change: 0 additions & 1 deletion build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { build, BuildOptions } from "esbuild";
build({
...opts,
format: "cjs",
define: { "import.meta.url": "__filename" },
}),
build({
...opts,
Expand Down
4 changes: 0 additions & 4 deletions esbuild-register.js

This file was deleted.

8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import os from "os";
import fs from "fs";
import path from "path";
import crypto from "crypto";
import { pathToFileURL } from "url";
import anyMatch from "anymatch";
import { pathToFileURL, fileURLToPath } from "url";
import getServerEntryTemplate from "./server-entry-template";
import {
generateInputDoc,
Expand Down Expand Up @@ -46,6 +46,8 @@ const virtualFileQuery = "?marko-virtual";
const markoExt = ".marko";
const htmlExt = ".html";
const resolveOpts = { skipSelf: true };
const thisFile =
typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
let tempDir: Promise<string> | undefined;

export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
Expand Down Expand Up @@ -125,11 +127,11 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {
if (!registeredTag) {
// Here we inject either the watchMode vite tag, or the build one.
const transformer = path.resolve(
import.meta.url,
thisFile,
"../render-assets-transform"
);
registeredTag = path.resolve(
import.meta.url,
thisFile,
"../components",
isBuild ? "vite.marko" : "vite-watch.marko"
);
Expand Down

0 comments on commit 31c7172

Please sign in to comment.