web-infra-dev / web-infra-dev/rslib
[Bug]: When in bundleless mode, rspack plugins do not call `normalModuleFactory.hooks.resolve` on import declarations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 67
- Avg merge
- 6h 9m
- Merged PRs (30d)
- 57
Description
Version
System:
OS: macOS 15.1.1
CPU: (10) arm64 Apple M1 Max
Memory: 96.69 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 141.0.7390.108
Firefox: 138.0.3
Safari: 18.1.1
npmPackages:
@rslib/core: ^0.16.0 => 0.16.0
Details
When rslib is set to output in bundleless mode (bundle: false), any registered rspack plugins do not call the normalModuleFactory.hooks.resolve hook on import declarations in the source files.
When rslib is set to output in bundleless mode (bundle: false), a rspack plugin provided to the rslib configuration (tools.rspack.plugins) will not call the normalModuleFactory.hooks.resolve hook for imports in the source files. It will call it on the result of the source.entry glob, but it does not loop through the imports of each source file, calling the hook, as I would expect.
I would expect this especially because it does call the beforeResolve hook on these imports, but then does not call resolve.
This is needed for my use case, as I am using a plugin that, combined with a component library, generates CSS files at build time. It will add the imports to the source files as needed, and then it waits for the the resolve to be called on the path, in order to write out the corresponding CSS file. Because resolve is not being called, the plugin is failing to write out the CSS files.
Reproduce link
https://github.com/davidferguson/rslib-bundle-noresolve
Reproduce Steps
Described in the reproduction repo readme
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction repository and its README, then inspect how bundleless mode processes the source.entry glob and imports when tools.rspack.plugins are configured. Compare the beforeResolve and resolve hook behavior for import declarations. Done means the normalModuleFactory.hooks.resolve hook runs for those imports so the plugin can generate its CSS files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100