GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(asset): return the asset url from a direct importModule() call by lazerg · Pull Request #22864 · webpack/webpack

Conversation

@lazerg

@lazerg lazerg commented Oct 23, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Fixes #22863. importModule() adds its dependency with connectOrigin: false, so AssetGenerator.getTypes() skipped that connection and gave the asset no JavaScript output. The build-time execution then had nothing to run (and no __webpack_require__.p), so the loader got {}. Now a loader-import connection counts as a JavaScript consumer, the same way CssGenerator already handles it.

await this.importModule(`${this.resourcePath}.webpack[asset/resource]!=!${this.resourcePath}`);
// before: {}
// after:  "/asset.txt"

asset/inline had the same problem and now returns the data url.

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes, test/configCases/loader-import-module/asset-resource/ (resource and inline).

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?

n/a

Use of AI

Yes, Claude Code helped trace the cause and write the test. I checked the fix against the issue's repro and ran the tests and yarn lint locally.

Summary by CodeRabbit

  • Bug Fixes
    • Asset modules loaded through importModule() now return the expected value: a public URL for resource assets or a data URL for inline assets. This ensures both asset types resolve correctly when imported through a loader.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lazerg
fix(asset): return the asset url from a direct importModule() call
fbc0e82
@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1af63ae

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai coderabbitai Bot added area: loaders Loader execution and loader API (lib/loaders) regression Worked in a previous release; pair with the Affected version field labels Oct 23, 2026
@lazerg
test: use a text fixture for the importModule asset case
1af63ae
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 759b539
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 07c89ac4-036f-4151-84a0-a85315eb6651
📥 Commits

Reviewing files that changed from the base of the PR and between fbc0e82 and 1af63ae.

📒 Files selected for processing: 4
  • .changeset/060-import-module-asset-url.md
  • test/configCases/loader-import-module/asset-resource/file.txt
  • test/configCases/loader-import-module/asset-resource/index.js
  • test/configCases/loader-import-module/asset-resource/webpack.config.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

AssetGenerator now treats origin-less loader-import connections as JavaScript consumers. A config case tests URLs returned for asset/resource and asset/inline imports.

Changes: Loader-import asset URLs

Layer / File(s) Summary
Classify loader-import connections
lib/asset/AssetGenerator.js, .changeset/060-import-module-asset-url.md
AssetGenerator sets consumer flags for origin-less connections with a loader-import dependency. The changeset describes the URL behavior for direct importModule() loads.
Test resource and inline asset URLs
test/configCases/loader-import-module/asset-resource/*
The config selects asset/resource or asset/inline by query. The loader imports the asset and returns its URL; the test checks the expected URL values.

Suggested labels: area: loaders, regression

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 1af63

The change correctly returns resource and inline asset URLs from direct importModule calls, with targeted coverage for both behaviors.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title uses the required Conventional Commit format and accurately describes the asset URL fix. The branch name is not provided, so the required match between the commit type and branch prefix cann… Provide the branch name or branch prefix. Confirm that it starts with the fix prefix.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check Passed Issue #22863 requires loaderContext.importModule() to return the emitted URL for an explicit asset/resource request. AssetGenerator.getTypes() now treats a loader-import connection without an …
Out of Scope Changes check Passed The source change directly fixes the connection handling required by issue #22863. The asset/resource and asset/inline tests exercise that behavior. The changeset documents the fix. No unrelated c…
Full details: Linked Issues check

Explanation

Issue #22863 requires loaderContext.importModule() to return the emitted URL for an explicit asset/resource request. AssetGenerator.getTypes() now treats a loader-import connection without an origin module as a JavaScript consumer. The added config case verifies the /public/assets/file.txt result. The implementation also verifies the related asset/inline data URL behavior.

Full details: Out of Scope Changes check

Explanation

The source change directly fixes the connection handling required by issue #22863. The asset/resource and asset/inline tests exercise that behavior. The changeset documents the fix. No unrelated change is demonstrated.

Full details: Title check

Explanation

The title uses the required Conventional Commit format and accurately describes the asset URL fix. The branch name is not provided, so the required match between the commit type and branch prefix cannot be verified.

Resolution

Provide the branch name or branch prefix. Confirm that it starts with the fix prefix.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

malash
malash approved these changes Oct 23, 2026
View reviewed changes
@alexander-akait

alexander-akait commented Oct 23, 2026

Copy link
Copy Markdown
Member

#22869, fixed here with more fixes, anyway thanks for this PR and helping

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait alexander-akait closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@malash malash malash approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area: loaders Loader execution and loader API (lib/loaders) regression Worked in a previous release; pair with the Affected version field

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

loaderContext.importModule() returns {} for asset/resource instead of its URL

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@lazerg @alexander-akait @malash
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.