Skip to content

fix(binding): preserve function-valued chunk filename templates - #15375

Draft
SyMind wants to merge 1 commit into
mainfrom
chunk-filename-template-function
Draft

fix(binding): preserve function-valued chunk filename templates#15375
SyMind wants to merge 1 commit into
mainfrom
chunk-filename-template-function

Conversation

@SyMind

@SyMind SyMind commented Aug 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Return the original JavaScript filename function from Chunk.filenameTemplate while preserving existing string and undefined behavior.
  • Track filename function references per compiler with weak Rust ownership, cleaning up expired references after compilation and releasing them when the compiler closes.
  • Support filename functions originating from entry options, split chunks, addEntry, and addInclude, with updated types, documentation, and integration coverage.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@SyMind

SyMind commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3037d67
Status: ✅  Deploy successful!
Preview URL: https://91eb63f6.rspack-v2.pages.dev
Branch Preview URL: https://chunk-filename-template-func.rspack-v2.pages.dev

View logs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3037d677df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +194 to +197
if let Some(manager) = CompilerScopedFilenameTsFnManager::current_context() {
let function_ref = JsFilenameFunctionRef::from_napi_value(env, napi_val)?;
manager.register(Arc::downgrade(&filename_fn), function_ref);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Register filename functions returned by dynamic entries

When entry is a function and its eventual RawEntryDynamicResult.options.filename is function-valued, JsFilename::from_napi_value runs while converting the promise result in raw_dynamic_entry.rs, after the constructor-time manager scope has ended. Consequently current_context() is None, no function reference is registered, and the resulting chunk's filenameTemplate getter returns undefined instead of the original function even though that function controls the emitted filename. The filename manager must also be propagated through conversion of dynamic-entry callback results.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 3037d67 to docs: remove version info before Rspack 1.3.0 (#15371) by Jiahan Chen

❌ Size increased by 8.00KB from 68.24MB to 68.24MB (⬆️0.01%)

@github-actions

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 556.5 KB 0 0
react-10k 5.6 MB 1.3 MB 0 0
react-1k 823.1 KB 218.4 KB 0 0
react-5k 2.7 MB 669.3 KB 0 0
ui-components 4.9 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 50 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing chunk-filename-template-function (3037d67) with main (aa2ea64)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@SyMind
SyMind marked this pull request as draft August 28, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant