This repository was archived by the owner on Sep 4, 2026. It is now read-only.
docs: deprecate the loader - #277
Merged
Merged
Conversation
Assigning a module to the global object needs no loader: it is one line where the file is yours, and an appended line through `NormalModule`'s `processResult` hook where it is not. The README now says so, and points at webpack's expose-global example for the second form.
The example keeps the plugin in the configuration rather than in a file of its own, so the snippet shows the class where the example puts it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #277 +/- ##
=======================================
Coverage 72.99% 72.99%
=======================================
Files 4 4
Lines 137 137
Branches 51 51
=======================================
Hits 100 100
Misses 24 24
Partials 13 13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Marks the loader deprecated in the README and gives the migration in two forms: the one line where the file is yours (
import { jQuery as $ } from "jquery"; globalThis.$ = $;), and theprocessResultplugin where it is not, linking to webpack's expose-global example (webpack/webpack#21952) as a working copy of it.Neither form wraps the module in a second one, which is what the loader has to do — and what #25, #227 and #256 are about, so the README says which of them each form settles. It also notes the two things that decide whether the assignment runs: something has to import the module, and a file in a
"sideEffects": falsepackage needs{ test: /…/, sideEffects: true }.Documentation only —
src/is untouched, so the loader keeps working exactly as it does today.Refs #25, refs #227, refs #256
What kind of change does this PR introduce?
docs
Did you add tests for your changes?
No — README only, no source change.
npm test(68 tests) andnpm run lintpass unchanged.Does this PR introduce a breaking change?
No. The loader is unchanged; the deprecation is a notice, not a behavior change.
npm deprecateand archiving remain separate decisions.If relevant, what needs to be documented once your changes are merged or what have you already documented?
webpack.js.org's
expose-loaderpage can carry the same notice and point at the example.Use of AI
Written with Claude Code, reviewed and directed by me: the migration guide and the snippet were produced in that session, the snippet mirrors the merged example, and the claims about what the loader's wrapper module costs were checked against real builds before being written down.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XWZM9YmKFi3ZeziHv69S4Q
Generated by Claude Code