-
-
Notifications
You must be signed in to change notification settings - Fork 760
feat: consume js inputFileSystem on the rust side
#8643
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: consume js inputFileSystem on the rust side
#8643
Conversation
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
e46d8a3 to
3162187
Compare
inputFileSystem on the rust sideinputFileSystem on the rust side
086d822 to
7a4d76e
Compare
|
Hi guys, I have been struggling to investigate the CI "Test Node 18" failure for 2 days. I feel I really need your help. I believe my implementation can pass all the tests if the tests are run separately. My findings so far are that it's stuck in
even if the output is the same. |
|
thanks it maybe related to performance regression, block_on fs binding will cause huge performance regression I think the biggest blocker now is rspack_resolver doesn't use async_fs, which cause it has to block_on on fs binging call, which will introduce huge performance regression rstackjs/rspack-resolver#34. but we can still merge this pr first if we don't enable input_fs binding by default and when we solve the rspack_resolver async_fs problem, we can enable inputfs binding |
|
yeah, I also suspect the performance regression, but cannot prove it. I'm afraid we cannot merge this PR now, because rspack/packages/rspack/src/rspack.ts Lines 53 to 62 in 5ad5803
and rspack/packages/rspack/src/node/NodeEnvironmentPlugin.ts Lines 49 to 53 in 9e1205c
if you feel the refactors in this pr are needed, I can create a new pr and cherry pick the refactor commits. |
I actually tried it before and revert cause huge performance regression introduced, you can test it in project with large modules like https://github.com/hardfist/performance-compare-ng/tree/master/apps/10000 |
that's easy, you can just ignore the inputFileSystem in the rust side, it's actually current's behavior |
|
I disabled I also created another branch and cherry-picked the refactor commits. maybe #8654 is exactly what you expect. |
yes, good job! |
e4a3ede to
c588351
Compare
CodSpeed Performance ReportMerging #8643 will not alter performanceComparing Summary
|
40336e8 to
f5e3b9b
Compare
b04fe0c to
ae04347
Compare
|
@nilptr @stormslowly 你们好,这个 pr 是不是可以支持使用社区的 webpack-virtual-module 的了? |
Yes, i will make a canary version; could you please give it try later? |
ok,thanks. let's talking in Lark. |
|
The canary supports virtual module is add below config in you config file you can reference here https://rspack.dev/guide/start/quick-start#install-canary-version for usage. |
|
感谢 @stormslowly @nilptr 兄的付出 ,1.3.10-canary-4a96390f-20250514074254 版本,已经可以正常运行 webpack-virtual-modules |
|
发现了一个新问题,当使用虚拟模块作为入口文件时,输出的虚拟 js 文件内容为空,并引发了 rspack panic 最小复现 demo 在这里 https://github.com/watsonhaw5566/rspack-virtual-modules-addentry-demo 初步猜想是 compilation.addEntry 当前仅支持真实路径文件,而不支持虚拟文件路径。 |
|
@watsonhaw5566 there are a few issues with your implementation.
|
Thank you suggestions , I'm modify to EntryDependency('./entry.js') , but it will make the Rspack Panic. |
Don't call It looks like your issues are unrelated to the purpose of this PR. To keep the thread focused, please move this discussion to a new thread in the Discussions section if needed. |
|
📝 Benchmark detail: Open
|
inputFileSystem on the rust sideinputFileSystem on the rust side
inputFileSystem on the rust sideinputFileSystem on the rust side
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.
Pull Request Overview
Add support for consuming the JavaScript inputFileSystem on the Rust side by introducing a hybrid filesystem that dispatches reads between Node.js and native Rust FS based on an allowlist.
- Introduce a new
useInputFileSystemexperiment option and default it tofalse. - Implement
ThreadsafeInputNodeFSin TypeScript andHybridFileSystemin Rust to route file operations. - Wire the new experiment through normalization, defaults, compiler binding, and update core API docs and tests.
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/config/types.ts | Define new useInputFileSystem option type |
| packages/rspack/src/config/normalization.ts | Normalize the new experiment setting |
| packages/rspack/src/config/defaults.ts | Set default value for useInputFileSystem |
| packages/rspack/src/FileSystem.ts | Add ThreadsafeInputNodeFS and shared __to_binding_stat helper |
| packages/rspack/src/Compiler.ts | Wire useInputFileSystem into compiler bindings |
| crates/node_binding/src/lib.rs | Pass inputFileSystem through JS-to-Rust binding |
| crates/node_binding/src/fs_node/hybrid.rs | Implement HybridFileSystem in Rust |
Comments suppressed due to low confidence (4)
packages/rspack/src/config/types.ts:2631
- [nitpick] The JSDoc for
UseInputFileSystemcould be expanded to clarify that providing aRegExp[]acts as an allowlist of paths that should use the Node.js filesystem rather than the Rust filesystem.
/**
packages/rspack/src/Compiler.ts:849
- Consider adding unit or integration tests for the
useInputFileSystemflag to verify that enabling and disabling the hybrid filesystem routing works as intended.
this.inputFileSystem && options.experiments.useInputFileSystem
packages/rspack/src/FileSystem.ts:98
- Missing imports for
utilandmemoizeFnat the top of this file. For example, addimport util from 'util';and importmemoizeFnfrom its defining module so these calls don’t cause runtime errors.
this.readDir = memoizeFn(() => {
packages/rspack/src/config/defaults.ts:258
- [nitpick] Minor grammar: consider rephrasing to "Enabling
useInputFileSystemintroduces additional filesystem overhead, so it is disabled by default."
// Enable `useInputFileSystem` will introduce much more fs overheads, So disable by default.
packages/rspack-test-tools/tests/watchCases/build-chunk-graph/chunk-modify/test.config.js
Outdated
Show resolved
Hide resolved
da7ec5e to
2f93d9e
Compare
|
thanks |
Summary
close #5091
inputFileSystemto decide one file should node.js FS or rust FS.Checklist