-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Use url.pathToFileURL to correctly resolve functions paths on windows #3412
Conversation
import * as fs from 'fs/promises'; | ||
import { TOOLPAD_DATA_PROVIDER_MARKER, ToolpadDataProvider } from '@toolpad/studio-runtime/server'; | ||
import * as z from 'zod'; | ||
import { fromZodError } from 'zod-validation-error'; | ||
import * as crypto from 'crypto'; | ||
|
||
async function loadExports(filePath: string): Promise<Map<string, unknown>> { | ||
const fullPath = path.resolve(filePath); | ||
const content = await fs.readFile(fullPath, 'utf-8'); | ||
const importFileUrl = url.pathToFileURL(path.resolve(filePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const importFileUrl = url.pathToFileURL(path.resolve(filePath)); | |
// Correct cross-platform resolution of the import URL | |
// See: https://nodejs.org/api/url.html#urlpathtofileurlpath | |
const importFileUrl = url.pathToFileURL(path.resolve(filePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 I thought it deserves special placement because of the bug. Perhaps we can link to the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I've added a comment
Fixes #3405
Use
url.pathToFileURL
to correctly resolve paths on windows