-
-
Notifications
You must be signed in to change notification settings - Fork 620
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
[Feature]: virtual module support #7478
Comments
This probably can split into two layer: memory input filesystem and virtual modules plugin, memory input filesystem for more general use cases and virtual modules plugin is just a wrapper plugin based on memory input filesystem |
yeah, that's the plan, but when you say "memory input filesystem" you mean
|
Definitely the second one, but we need to consider to make a better API for user. A MemoryFileSystemRspackPlugin or an enum/options of compiler.inputFileSystem that passes to rust |
yes, I will make a RFC about InputFilesystem and VirtualModule support |
This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
bump |
这个 feature 还有在进行吗, hardfist 兄 |
no, maybe we will use inputFs to implement when we solve the performance problem |
What problem does this feature solve?
Definition
Virtual Module: module not exists on real filesystem
Background
Virtual module is widely used in bundler ecosystem( vite、webpack), and different bundlers take different approaches,
webpack uses https://www.npmjs.com/package/webpack-virtual-modules?activeTab=readme to support virtual module and vite use https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention to support virtual module
Currently rspack implement a naive implementation of webpack-virtual-modules(https://github.com/rspack-contrib/rspack-plugins/tree/main/packages/plugin-virtual-module) which has some limitation.
Since Rspack already supports unplugin so it can actually support both implementation, but too many flexibilities may but ecosystem in chaos(just like vite's virtual module path can be
virtual:my-module
and\0xxx
which makes it harder to unify plugin usage).resolve hook vs input_filesystem
webpack use patched input_filesystem to implement virtual modules which limits virtual module path to be real path url(which may be not bad), so the internal resolver can handle it correctly, vite & rollup use resolve and load and virtual-module-convention to handle virtual path(which is more flexible).
It seems webpack-virtual-modules using patched input_filesystem strategy is not a strong limitation in real world usage and is much simpler and performance friendly.
There're 3 ways Rspack can implement virtual module like webpack did
It seems the second way is more flexible and ecosystem friendly, we may need to investigate the performance regression, if the regression is acceptable we can be compatible with webpack-virtual-modules, then do we still need implement a virtualModulePlugin for better out of box experience.
What does the proposed API of configuration look like?
if we choose implement rust version of this plugin then same as https://www.npmjs.com/package/webpack-virtual-modules
The text was updated successfully, but these errors were encountered: