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: incorrect filepath resolution during dynamic import #91

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion plugin/src/core/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { build } from 'esbuild'
import JSON5 from 'json5'
import type { Alias } from 'vite'
import url from "url";

Check failure on line 9 in plugin/src/core/compiler.ts

View workflow job for this annotation

GitHub Actions / lint

`url` import should occur before type import of `esbuild`

Check failure on line 9 in plugin/src/core/compiler.ts

View workflow job for this annotation

GitHub Actions / lint

Prefer `node:url` over `url`

Check failure on line 9 in plugin/src/core/compiler.ts

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 9 in plugin/src/core/compiler.ts

View workflow job for this annotation

GitHub Actions / lint

Extra semicolon

/* ===== esbuild begin ===== */

Expand Down Expand Up @@ -169,7 +170,7 @@
}: LoadFromCodeOptions): Promise<T | { [key: string]: T }> {
filepath = path.resolve(cwd, filepath)
const ext = isESM ? '.mjs' : '.cjs'
const file = `${filepath}.timestamp-${Date.now()}${ext}`
const file = url.pathToFileURL(`${filepath}.timestamp-${Date.now()}${ext}`)
await fsp.writeFile(file, code, 'utf8')
try {
const mod = await import(file)
Expand Down
Loading