-
Notifications
You must be signed in to change notification settings - Fork 111
feat(rspeedy/core): support function in output.filename.*
#1449
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(rspeedy/core): support function in output.filename.*
#1449
Conversation
🦋 Changeset detectedLatest commit: 254895f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThe changes introduce support for specifying output filenames as either static strings or dynamic functions in the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes were found. Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging #1449 will not alter performanceComparing Summary
|
Web Explorer#3790 Bundle Size — 342.64KiB (0%).254895f(current) vs 8d3f3f8 main#3777(baseline) Bundle metrics
Bundle size by type
|
| Current #3790 |
Baseline #3777 |
|
|---|---|---|
227.85KiB |
227.85KiB |
|
82.95KiB |
82.95KiB |
|
31.84KiB |
31.84KiB |
Bundle analysis report Branch colinaaa:colin/0806/output-filen... Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#3795 Bundle Size — 235.26KiB (0%).254895f(current) vs 8d3f3f8 main#3782(baseline) Bundle metrics
|
| Current #3795 |
Baseline #3782 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
159 |
159 |
|
64 |
64 |
|
45.81% |
45.81% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #3795 |
Baseline #3782 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
89.5KiB |
89.5KiB |
Bundle analysis report Branch colinaaa:colin/0806/output-filen... Project dashboard
Generated by RelativeCI Documentation Report issue
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/rspeedy/core/src/config/output/filename.ts (3)
123-147: Fix undefined variable in example.The example references
isProdwithout defining it, which could confuse users trying to implement this pattern.Apply this diff to fix the undefined variable:
- if (pathData.chunk?.name === 'index') { - return isProd ? '[name].[contenthash:8].js' : '[name].js'; - } + if (pathData.chunk?.name === 'index') { + return process.env.NODE_ENV === 'production' ? '[name].[contenthash:8].js' : '[name].js'; + }
157-181: Fix undefined variable in example.The example references
isProdwithout defining it, same issue as in the js property example.Apply this diff to fix the undefined variable:
- if (pathData.chunk?.name === 'index') { - return isProd ? '[name].[contenthash:8].css' : '[name].css'; - } + if (pathData.chunk?.name === 'index') { + return process.env.NODE_ENV === 'production' ? '[name].[contenthash:8].css' : '[name].css'; + }
236-236: Consider adding consistency with optional property typing.The new
wasmandassetsproperties don't include| undefinedin their type definitions, unlike other properties in the interface. This could lead to type inconsistencies.For consistency with other properties, consider applying this diff:
- wasm?: Rspack.WebassemblyModuleFilename + wasm?: Rspack.WebassemblyModuleFilename | undefined- assets?: Rspack.AssetModuleFilename + assets?: Rspack.AssetModuleFilename | undefinedAlternatively, if the new pattern is preferred, consider updating all other properties for consistency.
Also applies to: 247-247
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.changeset/bumpy-cameras-make.md(1 hunks).changeset/tasty-ends-report.md(1 hunks)packages/rspeedy/core/etc/rspeedy.api.md(1 hunks)packages/rspeedy/core/src/config/output/filename.ts(7 hunks)packages/rspeedy/core/test/config/output.test-d.ts(2 hunks)packages/rspeedy/core/test/plugins/output.plugin.test.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.
📚 Learning: in the lynx-family/lynx-stack repository, ci checks require changesets when files matching the patte...
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.
Applied to files:
.changeset/tasty-ends-report.md.changeset/bumpy-cameras-make.md
📚 Learning: in the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end...
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.
Applied to files:
.changeset/tasty-ends-report.md.changeset/bumpy-cameras-make.md
🧬 Code Graph Analysis (1)
packages/rspeedy/core/test/config/output.test-d.ts (1)
packages/rspeedy/core/src/config/output/index.ts (1)
Output(16-372)
🔇 Additional comments (8)
.changeset/tasty-ends-report.md (1)
1-6: LGTM! Appropriate changeset for user-facing feature.The changeset correctly documents the new function support in
output.filename.*configuration as a patch release. This is a meaningful enhancement that users will benefit from, making the changeset entry warranted per the project's conventions..changeset/bumpy-cameras-make.md (1)
1-6: LGTM! Complementary changeset for new filename options.The changeset appropriately documents the addition of
wasmandassetsfilename configuration options. This pairs well with the function support changeset and represents meaningful user-facing functionality.packages/rspeedy/core/test/config/output.test-d.ts (2)
4-4: LGTM! Appropriate import for enhanced type testing.The
Rspackimport enables proper type assertions for theAssetInfoparameter in filename functions.
154-284: Excellent comprehensive type coverage for filename configurations.The type tests thoroughly validate all aspects of the new filename functionality:
- ✅ All asset types (js, css, svg, font, image, media, wasm, assets) covered
- ✅ Both string and function forms tested for each type
- ✅ Function parameter types properly asserted (pathData, assetInfo)
- ✅ Special case for
wasmcorrectly shows function form is unsupported- ✅ Proper use of
@ts-expect-errorfor invalid configurationsThis provides robust type safety validation for the new feature.
packages/rspeedy/core/etc/rspeedy.api.md (1)
185-196: LGTM! API interface properly updated with enhanced typing.The
Filenameinterface changes correctly reflect the new functionality:
- ✅ More specific
Rspack.*types enable function support for existing properties- ✅ New
assetsandwasmproperties expand configuration options- ✅ Type specificity aligns with the different filename requirements per asset type
- ✅ Maintains backward compatibility with existing string configurations
The API documentation accurately represents the enhanced filename configuration capabilities.
packages/rspeedy/core/test/plugins/output.plugin.test.ts (1)
762-970: Excellent comprehensive runtime test coverage for filename configurations.The test suite thoroughly validates the new filename functionality across all asset types:
Strengths:
- ✅ Complete coverage of string and function forms for all asset types
- ✅ Proper validation of CSS plugin integration (filename + chunkFilename)
- ✅ Efficient parameterized testing for asset types (svg, image, media, font, assets)
- ✅ Correct verification of module rule configuration for asset generators
- ✅ WebAssembly-specific validation for string-only support
- ✅ Edge case testing (empty CSS distPath)
Implementation Quality:
- ✅ Tests verify actual build configuration output, not just mocked behavior
- ✅ Proper assertions using
expect.any(Function)for function validation- ✅ Realistic test scenarios with appropriate asset configurations
This provides robust runtime validation that complements the type tests perfectly.
packages/rspeedy/core/src/config/output/filename.ts (2)
5-5: LGTM!The import of Rspack types is necessary and correctly structured for the new function-based filename support.
147-147: LGTM!The type changes correctly map each property to its appropriate Rspack filename type:
js→Rspack.Filename(supports functions for JS files)css→Rspack.CssFilename(specific for CSS files)- Asset types →
Rspack.AssetModuleFilename(for asset modules)This enables function-based dynamic filename generation as intended.
Also applies to: 181-181, 192-192, 203-203, 214-214, 225-225
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @lynx-js/[email protected] ### Patch Changes - Supports `recyclable` attribute in `<list-item>` to control whether the list item is recyclable. The `recyclable` attribute depends on Lynx Engine 3.4 or later. ([#1388](#1388)) ```jsx <list-item recyclable={false} /> ``` - feat: Support using a host element as direct child of Suspense ([#1455](#1455)) - Add profile in production build: ([#1336](#1336)) 1. `diff:__COMPONENT_NAME__`: how long ReactLynx diff took. 2. `render:__COMPONENT_NAME__`: how long your render function took. 3. `setState`: an instant trace event, indicate when your setState was called. NOTE: `__COMPONENT_NAME__` may be unreadable when minified, setting `displayName` may help. - Add `onBackgroundSnapshotInstanceUpdateId` event on dev for Preact Devtools to keep the correct snapshotInstanceId info. ([#1173](#1173)) - fix: Prevent error when spreading component props onto an element ([#1459](#1459)) - fix: Correctly check for the existence of background functions in MTS ([#1416](#1416)) ```ts function handleTap() { "main thread"; // The following check always returned false before this fix if (myHandleTap) { runOnBackground(myHandleTap)(); } } ``` ## @lynx-js/[email protected] ### Patch Changes - Remove the experimental `provider` option. ([#1432](#1432)) - Add `output.filename.wasm` and `output.filename.assets` options. ([#1449](#1449)) - fix deno compatibility ([#1412](#1412)) - Should call the `api.onCloseBuild` hook after the build finished. ([#1446](#1446)) - Bump Rsbuild v1.4.15. ([#1423](#1423)) - Support using function in `output.filename.*`. ([#1449](#1449)) ## [email protected] ### Patch Changes - Support ESLint for ReactLynx templates ([#1274](#1274)) ## @lynx-js/[email protected] ### Patch Changes - Updated dependencies \[[`c8ce6aa`](c8ce6aa)]: - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - Fix the `Package subpath './compat' is not defined by "exports"` error. ([#1460](#1460)) ## @lynx-js/[email protected] ### Patch Changes - Fix `GlobalEventEmitter` type definition, the `emit(eventName: string, data: unknown)` function should recevie an array typed `data` and pass as param list of listeners. ([#1479](#1479)) ## @lynx-js/[email protected] ### Patch Changes - fix: load main-thread chunk in ESM format ([#1437](#1437)) See [nodejs/node#59362](nodejs/node#59362) for more details. - feat: support path() for `createQuerySelector` ([#1456](#1456)) - Added `getPathInfo` API to `NativeApp` and its cross-thread handler for retrieving the path from a DOM node to the root. - Implemented endpoint and handler registration in both background and UI threads. - Implemented `nativeApp.getPathInfo()` - Updated dependencies \[]: - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - fix: load main-thread chunk in ESM format ([#1437](#1437)) See [nodejs/node#59362](nodejs/node#59362) for more details. - feat: support path() for `createQuerySelector` ([#1456](#1456)) - Added `getPathInfo` API to `NativeApp` and its cross-thread handler for retrieving the path from a DOM node to the root. - Implemented endpoint and handler registration in both background and UI threads. - Implemented `nativeApp.getPathInfo()` - fix: when `onNativeModulesCall` is delayed in mounting, the NativeModules execution result may be undefined. ([#1457](#1457)) - fix: `onNativeModulesCall` && `onNapiModulesCall` use getter to get. ([#1466](#1466)) - Updated dependencies \[[`29434ae`](29434ae), [`fb7096b`](fb7096b)]: - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - fix: load main-thread chunk in ESM format ([#1437](#1437)) See [nodejs/node#59362](nodejs/node#59362) for more details. ## @lynx-js/[email protected] ### Patch Changes - feat: add autocomplete attribute support for x-input component ([#1444](#1444)) Implements autocomplete attribute forwarding from the x-input custom element to the internal HTML input element in the shadow DOM. This enables standard browser autocomplete functionality for x-input elements. - Add referrerpolicy attribute support to x-image web component ([#1420](#1420)) - Updated dependencies \[]: - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - fix: load main-thread chunk in ESM format ([#1437](#1437)) See [nodejs/node#59362](nodejs/node#59362) for more details. - Updated dependencies \[[`29434ae`](29434ae), [`fb7096b`](fb7096b)]: - @lynx-js/[email protected] - @lynx-js/[email protected] ## @lynx-js/[email protected] ### Patch Changes - feat: support path() for `createQuerySelector` ([#1456](#1456)) - Added `getPathInfo` API to `NativeApp` and its cross-thread handler for retrieving the path from a DOM node to the root. - Implemented endpoint and handler registration in both background and UI threads. - Implemented `nativeApp.getPathInfo()` - Updated dependencies \[[`29434ae`](29434ae), [`fb7096b`](fb7096b)]: - @lynx-js/[email protected] - @lynx-js/[email protected] - @lynx-js/[email protected] ## [email protected] ## @lynx-js/[email protected] ## @lynx-js/[email protected] ## @lynx-js/[email protected] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary by CodeRabbit
New Features
Tests
close: #1448
Checklist