Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

Summary

This PR adds support for neutral platform in rspack, enabling prefetch and preload functionality for platforms that are neither web nor node. Previously, prefetch and preload were only available when the environment supports document APIs. With this change, neutral platforms can also utilize these features.

The main changes include:

  • Added platform configuration support with optional fields
  • Updated module chunk loading runtime to check for neutral platform
  • Updated CSS runtime to support neutral platform for prefetch/preload
  • Made platform target properties optional in TypeScript definitions

Checklist

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

Copilot AI review requested due to automatic review settings December 23, 2025 08:14
@LingyuCoder LingyuCoder requested a review from h-a-n-a as a code owner December 23, 2025 08:14
@netlify
Copy link

netlify bot commented Dec 23, 2025

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 44c6021
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/694a5f04970efa0008bd2637
😎 Deploy Preview https://deploy-preview-12534--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added release: refactor team The issue/pr is created by the member of Rspack. labels Dec 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to add support for neutral platform in rspack, enabling prefetch and preload functionality for platforms that are neither explicitly web nor node. The main approach is to conditionally include runtime document checks based on whether the platform is "neutral" (i.e., cannot be determined at compile time).

Key Issues Identified

  1. Critical Bug: The variable is_neutral_platform is used in multiple files but is never defined in any of the generate methods.
  2. Critical Bug: The type CompilerPlatform is imported but doesn't exist in rspack_core.
  3. Critical Bug: Compiler::new() is being called with an additional platform parameter that doesn't exist in its signature.
  4. Moderate Bug: The css_loading_with_hmr.ejs template is not updated to use the conditional document check pattern.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
module_chunk_loading_with_preload.ejs Adds conditional document check for neutral platforms in preload handler
module_chunk_loading_with_prefetch.ejs Adds conditional document check for neutral platforms in prefetch handler
module_chunk_loading.rs Passes is_neutral_platform to templates (but variable is undefined)
css/runtime/mod.rs Passes is_neutral_platform to CSS templates (but variable is undefined)
css_loading_with_preload.ejs Adds conditional document check for neutral platforms in CSS preload
css_loading_with_prefetch.ejs Adds conditional document check for neutral platforms in CSS prefetch
defaults.rs Updates test to handle tuple return from build method
builder/target.rs Adds From implementation to convert TargetProperties to CompilerPlatform
builder/mod.rs Updates build method to return tuple and pass platform to Compiler::new

The PR is incomplete and missing several critical pieces:

  • Definition of CompilerPlatform type
  • Calculation of is_neutral_platform variable
  • Updates to Compiler struct and new method to accept platform
  • Update to css_loading_with_hmr.ejs template

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
ui-components 2.1 MB 0
rome 984.3 KB 0
react-1k 823.4 KB 0
react-5k 2.7 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

📦 Binary Size-limit

Comparing 44c6021 to refactor: extract case-sensitive check to plugin (#12532) by harpsealjs

❌ Size increased by 8.13KB from 47.87MB to 47.88MB (⬆️0.02%)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 23, 2025

CodSpeed Performance Report

Merging #12534 will not alter performance

Comparing refactor/add-platform (44c6021) with main (650a863)

Summary

✅ 16 untouched
⏩ 1 skipped1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@LingyuCoder LingyuCoder enabled auto-merge (squash) December 23, 2025 09:34
@LingyuCoder LingyuCoder merged commit 1c5ec4b into main Dec 23, 2025
77 of 79 checks passed
@LingyuCoder LingyuCoder deleted the refactor/add-platform branch December 23, 2025 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants