Skip to content

refactor: inline loader-runner package into core#21249

Open
bjohansebas wants to merge 12 commits into
webpack:mainfrom
bjohansebas:refactor/inline-loader-runner
Open

refactor: inline loader-runner package into core#21249
bjohansebas wants to merge 12 commits into
webpack:mainfrom
bjohansebas:refactor/inline-loader-runner

Conversation

@bjohansebas

Copy link
Copy Markdown
Member

Summary

This comes from the roadmap

Same content, just with typos.

What kind of change does this PR introduce?

Did you add tests for your changes?

Does this PR introduce a breaking change?

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Use of AI

Copilot AI review requested due to automatic review settings June 22, 2026 19:48
@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 262242f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Patch

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bjohansebas bjohansebas marked this pull request as draft June 22, 2026 19:49
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.44073% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.89%. Comparing base (6e5bd5d) to head (262242f).
⚠️ Report is 45 commits behind head on main.

Files with missing lines Patch % Lines
lib/loaders/LoaderRunner.js 95.81% 12 Missing ⚠️
lib/loaders/loadLoader.js 91.17% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21249      +/-   ##
==========================================
+ Coverage   92.77%   92.89%   +0.11%     
==========================================
  Files         591      597       +6     
  Lines       64467    65307     +840     
  Branches    17911    18243     +332     
==========================================
+ Hits        59808    60665     +857     
+ Misses       4659     4642      -17     
Flag Coverage Δ
css-parsing 28.63% <29.26%> (-0.10%) ⬇️
html5lib 31.07% <29.26%> (-0.11%) ⬇️
integration 88.98% <85.10%> (+0.23%) ⬆️
test262 45.44% <30.48%> (-0.07%) ⬇️
unit 43.30% <94.20%> (+2.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Introduced multiple loader implementations including identity, async, promise, and pitch loaders.
- Added binary files for testing purposes, including 'bom.bin' and 'resource.bin'.
- Implemented loaders that handle dependencies, context dependencies, and missing dependencies.
- Created loaders that return modified source strings and handle raw data.
- Added tests for loaders that throw errors and return promises.
- Included examples of setting resource paths and handling async operations in loaders.
@codspeed-hq

codspeed-hq Bot commented Jun 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
❌ 3 regressed benchmarks
✅ 137 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 381.2 KB 1,195.3 KB -68.11%
Memory benchmark "wasm-modules-sync", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 131.8 KB 364.7 KB -63.86%
Memory benchmark "asset-modules-bytes", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 247 KB 322.6 KB -23.43%
Memory benchmark "many-modules-esm", scenario '{"name":"mode-development","mode":"development"}' 1.9 MB 1.2 MB +66.39%
Memory benchmark "many-chunks-esm", scenario '{"name":"mode-production","mode":"production"}' 11.4 MB 8.7 MB +31.34%
Memory benchmark "wasm-modules-async", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 250.2 KB 195.3 KB +28.13%
Memory benchmark "future-defaults", scenario '{"name":"mode-production","mode":"production"}' 8.7 MB 7.1 MB +23.58%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing bjohansebas:refactor/inline-loader-runner (262242f) with main (54fa902)

Open in CodSpeed

@bjohansebas bjohansebas marked this pull request as ready for review June 22, 2026 21:29
Copilot AI review requested due to automatic review settings June 22, 2026 21:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bjohansebas

bjohansebas commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@alexander-akait after this, I'm going to look into the improvements Rspack has regarding loader caching.

Comment thread lib/loaders/LoaderRunner.js Outdated
missingDependencies.length = 0;
requestCacheable = true;
};
Object.defineProperty(loaderContext, "resource", {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's use modern ES syntax here, also I am thinking about implement a function createLoaderContext and move from normal module all logic related to loader context in this function, so it will be more readable, now we have multiple places to create a loader context, it is not good

Copilot AI review requested due to automatic review settings June 26, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.


// add accessors last (keeps fast properties) and freeze, now that callers
// (e.g. NormalModule's beforeLoaders) have populated the context
Object.defineProperties(loaderContext, ACCESSORS);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using defineProperties is consistently faster than defineProperty or class methods. I saw roughly a 9% performance improvement, especially in cases like Babel and other similar tooling.

Copilot AI review requested due to automatic review settings June 26, 2026 22:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

3 participants