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

Đang mở
#23,271 8 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #23312 của @thisisvaishnav — đã đóng, không merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
build-system

Hướng nghiên cứu

Start with the reproduction repository and run pnpm run webpack and pnpm run webpack:baseline, then compare dist/webpack/with-rule/ against dist/webpack/baseline/. The bug is that with a javascript/auto rule for .js, new URL('./source.js', import.meta.url) resolves to [object Module] and webpack does not emit source.js. Done means the with-rule bundle emits source.js and prints the same URL as the baseline.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: parser area: runtime
Have you used AI?

Yes

Which part of webpack is affected?

not sure, config (options, defaults, validation)

Bug Description

new URL('./source.js', import.meta.url) to get a link to the original JavaScript file. When a rule sets type: 'javascript/auto' for all .js files, webpack compiles successfully, skips emitting the source file, and generates a URL ending in [object%20Module].

Link to Minimal Reproduction and steps to reproduce

The reproduction repository includes the emitted files. Clone it and run pnpm install --frozen-lockfile, then pnpm run webpack and pnpm run webpack:baseline.

Expected Behavior

The URL should point to the emitted copy of source.js, as it does in the baseline.

Actual Behavior

With the rule, webpack emits only dist/webpack/with-rule/bundle.cjs. Running it prints file:///…/dist/webpack/with-rule/[object%20Module].

Without the rule, webpack also emits dist/webpack/baseline/source.js. The bundle prints file:///…/dist/webpack/baseline/source.js, and cmp confirms that the emitted file matches the original byte for byte.

Environment
System:
  OS: macOS 27.2
  CPU: (18) arm64 Apple M5 Pro
  Memory: 48.00 GB
Binaries:
  Node: 24.15.0
  Yarn: 1.22.22
  npm: 11.12.1
  pnpm: 10.34.4
Packages:
  webpack: 5.112.2
  webpack-cli: 7.3.1
Is this a regression?

None

Last Working Version

No response

Additional Context

No response

Ngôn ngữ chính
JavaScript
Star
66k
Fork
9.7k
Merge trung bình
8 giờ 12 phút
Pull request đã merge (30 ngày)
541

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của webpack/webpack

Tất cả issue của webpack/webpack

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.