Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): try to resolve h3 from user node_modules first #94

Merged
merged 4 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/server/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { consola } from "consola";
import { dirname, join, resolve } from "pathe";
import type { ConsolaInstance } from "consola";
import { resolvePath } from "mlly";
import { createResolver } from "./_resolver";

export interface DevServerOptions {
Expand All @@ -17,14 +18,18 @@
) {
const logger = options.logger || consola.withTag("listhen");

const h3Entry = await resolvePath("h3", {
url: [options.cwd!, process.cwd(), import.meta.url].filter(Boolean),
});

Check warning on line 24 in src/server/dev.ts

View check run for this annotation

Codecov / codecov/patch

src/server/dev.ts#L21-L24

Added lines #L21 - L24 were not covered by tests
const {
createApp,
fromNodeMiddleware,
serveStatic,
eventHandler,
dynamicEventHandler,
toNodeListener,
} = await import("h3");
} = (await import(h3Entry)) as typeof import("h3");

Check warning on line 32 in src/server/dev.ts

View check run for this annotation

Codecov / codecov/patch

src/server/dev.ts#L32

Added line #L32 was not covered by tests

// Initialize resolver
const resolver = await createResolver();
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"module": "ESNext",
"moduleResolution": "Node",
"esModuleInterop": true,
"outDir": "dist",
Expand Down