René's URL Explorer Experiment


Title: rspack/webpack virtual modules can't do relative import · Issue #483 · unjs/unplugin · GitHub

Open Graph Title: rspack/webpack virtual modules can't do relative import · Issue #483 · unjs/unplugin

X Title: rspack/webpack virtual modules can't do relative import · Issue #483 · unjs/unplugin

Description: Environment unplugin@2.2.2 Node 23.4.0 Windows 11 version 10.0.26100 Build 26100 Reproduction Repo: https://github.com/edemaine/unplugin-rspack-relative-import Run: npm install npm run build Error: > rspack@1.0.0 build > rspack build ERR...

Open Graph Description: Environment unplugin@2.2.2 Node 23.4.0 Windows 11 version 10.0.26100 Build 26100 Reproduction Repo: https://github.com/edemaine/unplugin-rspack-relative-import Run: npm install npm run build Error:...

X Description: Environment unplugin@2.2.2 Node 23.4.0 Windows 11 version 10.0.26100 Build 26100 Reproduction Repo: https://github.com/edemaine/unplugin-rspack-relative-import Run: npm install npm run build Error:...

Opengraph URL: https://github.com/unjs/unplugin/issues/483

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"rspack/webpack virtual modules can't do relative import","articleBody":"### Environment\n\nunplugin@2.2.2\nNode 23.4.0\nWindows 11 version 10.0.26100 Build 26100\n\n### Reproduction\n\nRepo: https://github.com/edemaine/unplugin-rspack-relative-import\nRun:\n* `npm install`\n* `npm run build`\n\nError:\n\n```\n> rspack@1.0.0 build\n> rspack build\n\nERROR in ./node_modules/.virtual/C%3A%5CUsers%5Cedemaine%5CProjects%5Cunplugin-rspack-relative-import%5Csrc%5Cindex.civet.jsx 1:0-21\n  × Module not found: Can't resolve './index.css' in 'C:\\Users\\edemaine\\Projects\\unplugin-rspack-relative-import\\node_modules\\.virtual'\n   ╭─[1:7]\n 1 │ import \"./index.css\";\n   ·        ─────────────\n 2 │\n 3 │ document.querySelector(\"#root\").innerHTML = `\n   ╰────\n```\n\n### Describe the bug\n\nFrom #416 I gather that webpack/rspack virtual modules get put inside `node_modules/.virtual`. Then the relative import of `./index.css` is getting resolved within that directory, which fails.\n\n### Additional context\n\nI tried logging calls to `resolveId`, and I see the following:\n```\nresolveId(\"./src/index.civet\", undefined)\nresolveId(\"./index.css\", \"\\C:\\Users\\edemaine\\Projects\\Civet\\integration\\unplugin-examples\\rspack\\src\\index.civet.jsx\")\n```\n\nThis suggest to me that the virtual prefix is getting stripped incorrectly on Windows; I don't think the leading `\\` should be there. #421 might be the same issue, and #422 might fix this.\n\nBut I don't think that this is the cause for this particular bug. rspack itself isn't going to strip virtual module names; only unplugin will. So rspack is going to resolve relative paths incorrectly, unless they're handled by an unplugin. I'd rather not have my unplugin help resolve all files, only the ones it's supposed to do (`.civet`).\n\nI guess the workaround is for my unplugin's `resolveId` to fix the paths for all imports, perhaps when the `importer` is recognized as something my unplugin generated.\n\nI *think* a better fix would be to put virtual modules in the same directory as the source file. I understand that the `node_modules/.virtual` choice was made to avoid it appearing in VSCode or Git. But I don't see how relative imports could work in this scenario.\n\nLet me know what you think and I can try to work on a fix.\n","author":{"url":"https://github.com/edemaine","@type":"Person","name":"edemaine"},"datePublished":"2025-03-23T15:30:59Z","url":"https://github.com/unjs/unplugin/issues/483"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f6a4c3ec-79cf-4383-7edd-e5dd85882175
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9274:2E5D6B:592311:7972CE:6B00744D
html-safe-nonce6e9a32b59c3afad4ed646c745c2f9246ff17a410da08c53119bc16298a059547
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Mjc0OjJFNUQ2Qjo1OTIzMTE6Nzk3MkNFOjZCMDA3NDREIiwidmlzaXRvcl9pZCI6IjMyNjQwMTM0MzY5NDE1MzAxODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac5cd670cc6a7d90a27d33f8b1dd5205da25690f7b2bb722779883efb643da46e8
hovercard-subject-tagissue:2941265981
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/unjs/unplugin/483/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5b218deca7573cc683428899f695f114662f4b0921aceb4885a0871b9901bf97/unjs/unplugin/issues/483
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5b218deca7573cc683428899f695f114662f4b0921aceb4885a0871b9901bf97/unjs/unplugin/issues/483
og:image:altEnvironment unplugin@2.2.2 Node 23.4.0 Windows 11 version 10.0.26100 Build 26100 Reproduction Repo: https://github.com/edemaine/unplugin-rspack-relative-import Run: npm install npm run build Error:...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameedemaine
hostnamegithub.com
expected-hostnamegithub.com
None75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16
turbo-cache-controlno-preview
go-importgithub.com/unjs/unplugin git https://github.com/unjs/unplugin.git
octolytics-dimension-user_id80154025
octolytics-dimension-user_loginunjs
octolytics-dimension-repository_id385261169
octolytics-dimension-repository_nwounjs/unplugin
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id385261169
octolytics-dimension-repository_network_root_nwounjs/unplugin
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release84e563eb4b55f8fa102f325f117533cee9e3df4a
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/unjs/unplugin/issues/483#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Funjs%2Funplugin%2Fissues%2F483
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Funjs%2Funplugin%2Fissues%2F483
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=unjs%2Funplugin
Reloadhttps://github.com/unjs/unplugin/issues/483
Reloadhttps://github.com/unjs/unplugin/issues/483
Reloadhttps://github.com/unjs/unplugin/issues/483
unjshttps://github.com/unjs
unpluginhttps://github.com/unjs/unplugin
Codehttps://github.com/unjs/unplugin
Issues33 (33)https://github.com/unjs/unplugin/issues
Pull requests8 (8)https://github.com/unjs/unplugin/pulls
Actionshttps://github.com/unjs/unplugin/actions
Security and qualityhttps://github.com/unjs/unplugin/security
Insightshttps://github.com/unjs/unplugin/insights
https://github.com/unjs/unplugin
New issuehttps://github.com/login?return_to=https://github.com/unjs/unplugin/issues/483
New issuehttps://github.com/login?return_to=https://github.com/unjs/unplugin/issues/483
rspack/webpack virtual modules can't do relative importhttps://github.com/unjs/unplugin/issues/483#top
bugSomething isn't workinghttps://github.com/unjs/unplugin/issues?q=state%3Aopen%20label%3A%22bug%22
rspackhttps://github.com/unjs/unplugin/issues?q=state%3Aopen%20label%3A%22rspack%22
https://github.com/edemaine
edemainehttps://github.com/edemaine
on Mar 23, 2025https://github.com/unjs/unplugin/issues/483#issue-2941265981
https://github.com/edemaine/unplugin-rspack-relative-importhttps://github.com/edemaine/unplugin-rspack-relative-import
#416https://github.com/unjs/unplugin/pull/416
#421https://github.com/unjs/unplugin/issues/421
#422https://github.com/unjs/unplugin/pull/422
edemainehttps://github.com/edemaine
bugSomething isn't workinghttps://github.com/unjs/unplugin/issues?q=state%3Aopen%20label%3A%22bug%22
on Mar 23, 2025https://github.com/unjs/unplugin/issues/483#event-16944785120
https://github.com/sxzz
sxzzhttps://github.com/sxzz
on Mar 23, 2025https://github.com/unjs/unplugin/issues/483#issuecomment-2746276066
@SoonIterhttps://github.com/SoonIter
@chenjiahanhttps://github.com/chenjiahan
sxzzhttps://github.com/sxzz
rspackhttps://github.com/unjs/unplugin/issues?q=state%3Aopen%20label%3A%22rspack%22
on Mar 23, 2025https://github.com/unjs/unplugin/issues/483#event-16944798236
edemainehttps://github.com/edemaine
on Mar 23, 2025https://github.com/unjs/unplugin/issues/483#event-16944802705
https://github.com/edemaine
edemainehttps://github.com/edemaine
on Mar 23, 2025https://github.com/unjs/unplugin/issues/483#issuecomment-2746278506
https://github.com/chenjiahan
chenjiahanhttps://github.com/chenjiahan
on Mar 24, 2025https://github.com/unjs/unplugin/issues/483#issuecomment-2746682589
@hardfisthttps://github.com/hardfist
https://github.com/hardfist
hardfisthttps://github.com/hardfist
on Mar 26, 2025https://github.com/unjs/unplugin/issues/483#issuecomment-2753074951
@edemainehttps://github.com/edemaine
https://github.com/edemaine
edemainehttps://github.com/edemaine
on Mar 26, 2025https://github.com/unjs/unplugin/issues/483#issuecomment-2754710517
@hardfisthttps://github.com/hardfist
https://github.com/edemaine/unplugin-rspack-relative-importhttps://github.com/edemaine/unplugin-rspack-relative-import
https://github.com/hardfist
hardfisthttps://github.com/hardfist
on Mar 28, 2025https://github.com/unjs/unplugin/issues/483#issuecomment-2759938124
https://private-user-images.githubusercontent.com/8898718/427803626-6e239e16-3c2d-4cef-a868-abb38d93695d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUxOTIxODYsIm5iZiI6MTc5NTE5MTg4NiwicGF0aCI6Ii84ODk4NzE4LzQyNzgwMzYyNi02ZTIzOWUxNi0zYzJkLTRjZWYtYTg2OC1hYmIzOGQ5MzY5NWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MTEyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjExMjBUMTYyNDQ2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTJlMDBmNzZjYTBhM2NmYjE3OTg1ZDI4Nzc2ZDQ3NjJmNjMwNzMxZjVlMDk2MTNmOWI3OTIwYjMxNTIwZjI4OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.9gBKiQ--HeC19gNTHmCfoZJPOR0J9pDmAHJ0fLrqY8U
https://github.com/DanielXMoore/Civet/blob/0d97621082c7c0d2201d57498816b67ad95e8838/source/unplugin/unplugin.civet#L399https://github.com/DanielXMoore/Civet/blob/0d97621082c7c0d2201d57498816b67ad95e8838/source/unplugin/unplugin.civet#L399
https://github.com/hardfist
hardfisthttps://github.com/hardfist
on Mar 28, 2025https://github.com/unjs/unplugin/issues/483#issuecomment-2760044125
https://github.com/unjs/unplugin/blob/main/src/webpack/index.ts#L123https://github.com/unjs/unplugin/blob/main/src/webpack/index.ts#L123
Sign up for freehttps://github.com/signup?return_to=https://github.com/unjs/unplugin/issues/483
Sign in to commenthttps://github.com/login?return_to=https://github.com/unjs/unplugin/issues/483
bugSomething isn't workinghttps://github.com/unjs/unplugin/issues?q=state%3Aopen%20label%3A%22bug%22
rspackhttps://github.com/unjs/unplugin/issues?q=state%3Aopen%20label%3A%22rspack%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.