Replies: 2 comments
-
I believe the lack of this support is what causes dicebear to not work with Remix dicebear/dicebear#321 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm building a UI library for Remix/React and want the component's source code that's shown on the website to be the one from the components code on disk. This is the current state of afairs, in case you need the same. import { promises as fs } from 'fs'
import { fileURLToPath } from 'url'
import path, { dirname } from 'path'
import { useLoaderData } from '@remix-run/react'
export const loader = async () => {
const basePath = '../app/routes/'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const filePath = path.join(__dirname, basePath, '/_marketing+/ui+/components/typography/heading.tsx')
const source = await fs.readFile(filePath, 'utf-8')
return json({ source })
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What is the new or updated feature that you are suggesting?
Add support for
import.meta.url
as an alternative to__filename
and__dirname
Why should this feature be included?
It is a JavaScript/Web standard for getting the url to the current file. It's supported in node, deno, as well as the web. The alternatives
__dirname
and__filename
are supported in the CommonJS variant of node, but not when using ECMAScript Modules. You can easily recreate these variables withconst __dirname = new URL('./', import.meta.url).pathname
. #useThePlatformBeta Was this translation helpful? Give feedback.
All reactions