Visitar URL original
fix: keep .js files referenced via new URL() as assets despite a JS module rule by zeroaiproject · Pull Request #23306 · webpack/webpack · GitHub
Skip to content

fix: keep .js files referenced via new URL() as assets despite a JS module rule - #23306

Closed
zeroaiproject wants to merge 1 commit into
webpack:mainfrom
zeroaiproject:fix/url-asset-js-auto-rule
Closed

zeroaiproject wants to merge 1 commit into
webpack:mainfrom
zeroaiproject:fix/url-asset-js-auto-rule

Conversation

@zeroaiproject

Copy link
Copy Markdown

Summary

A url dependency resolves to an asset module by default. A generic rule (user-supplied or built-in) that turns .js files into a JavaScript module type must not override that, otherwise a new URL('./source.js', import.meta.url) expression ends up coercing the resolved module object to a string ([object Module]) and the source file is not emitted. Fixes #23271.

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes, added test/configCases/url/js-url-asset-with-auto-rule.

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

AI was used to investigate the root cause and implement the fix; the change was validated with the new config case and the existing test suite.

@changeset-bot

changeset-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ed7529d

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

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi there! This PR was automatically flagged and closed by our quality checks.

If you believe this was a mistake, please review our contributing guidelines
and leave a comment explaining why this is a mistake.

@github-actions github-actions Bot closed this Nov 13, 2026
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.

new URL('./source.js', import.meta.url) produces a URL ending in [object%20Module] with a javascript/auto rule

1 participant