-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(vite-plugin-markdown): support importing markdown files from outside root project #4780
Conversation
This change adds support for importing markdown located outside the root of directory of a project
|
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'm not positive about this change, but if this is all it takes to unblock this, that would be very exciting.
Suggestion: you can use new URL('../jsx-runtime/index.js', import.meta.url)
instead of manually manipulating the import.meta.url
string, then convert it to a Node path using fileURLToPath
, then convert it back to a proper import path with Vite's normalizePath
utility. It's roundabout, but a more robust approach than what you're doing here.
Thanks for the suggestion I refactored it. I hope this PR is not a works my machine thing |
This does seem difficult to test and I'm wary of taking on support for something that's fairly uncommon. It's pretty normal to need to have your files in the same folder as your project root on any framework. |
Fair enough this is quite uncommon (supporting imports for markdown imports in monorepo setups was the motivation behind this PR) and I don't know yet how I'd go about testing this. |
From my perspective this is actually a really common pattern! Imagine a top-level If this is all it takes to unblock that, I'd be super happy. |
Pattern I've seen repeated a lot in the repo
Interesting, I didn't think of that real world use case (just wanted to add that feature because why not 😅). Anyway, looking forward to getting suggestions before I'm able to submit the PR |
I'll remove my objection given @natemoo-re's reasoning. So once @natemoo-re is satisfied with the code I think it's ready to go. @MoustaphaDev can you mark this PR as being ready for review. |
Done ! |
Changes
This change adds support for importing markdown files from outside the root directory of a project, which is very common in monorepo setups
Testing
TODO - I'll need some assistance for this one
Docs
TODO - Not sure if it needs documentation but will do if guided
/cc @withastro/maintainers-docs for feedback!