Skip to content

Conversation

@alexander-akait
Copy link
Member

Summary

bugfix - resource, resourcePath, resourceQuery and resourceHash are always empty string

What kind of change does this PR introduce?

bugfix

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

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

Nothing

@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.74%. Comparing base (ac1e111) to head (1601878).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
- Coverage   92.77%   92.74%   -0.03%     
==========================================
  Files           3        3              
  Lines         263      262       -1     
==========================================
- Hits          244      243       -1     
  Misses         19       19              
Flag Coverage Δ
integration 92.74% <100.00%> (-0.03%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@alexander-akait alexander-akait merged commit 20e9fb8 into main Oct 8, 2025
32 checks passed
@alexander-akait alexander-akait deleted the fix-logic-for-empty-resource branch October 8, 2025 13:28
@lwr
Copy link

lwr commented Oct 9, 2025

Why a breaking change in a patch version?

Since 4.3.1, the null checking for loader resource are all breaks.

@alexander-akait
Copy link
Member Author

@lwr Potentially it is was a bug, but can side effect, our types was always string - https://github.com/webpack/webpack/blob/main/declarations/LoaderContext.d.ts#L213 (same for other values)

Since 4.3.1, the null checking for loader resource are all breaks.

if (resourcePath) {} will work as before

@lwr
Copy link

lwr commented Oct 10, 2025

Because this side effects breaks some builds, many of them without package-lock.json can not be recovered.

Can you please bump the version to 5.0.0, and revert it and re publish v4.3.2?

@alexander-akait
Copy link
Member Author

@lwr Can you provide link where it was broken? It is a bug and we can't fix it without breaking change on webpack side (changing types is breaking change too) or here (changing logic here is a little bit breaking change too), we decide to fix logic here (types preferred)

@lwr
Copy link

lwr commented Oct 10, 2025

@alexander-akait the breaking code is not in public, but I believed there should be somewhere, since the actual behavior nullable LoaderContext.resource & LoaderContext.resourcePath in fact for years.

We found broken codes in our private project like

export default function (source) {
    if (this.resource == null && this.query === '?preload') {
        return preloadIds.map(x => `import '${x}';`).join('\n');
    } else {
        return patchSource(source);
    }
}

It is easy to fix, but, history tags can never pass built without a patch.

@alexander-akait
Copy link
Member Author

this.resource can't be null, it is always string, webpack never supports null for resource, we have test cases inside webpack about this

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