allow wasm to be bundled
Chưa có ai nhận issue này.
Đá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
- 55/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- javascript, node.js, wasm
- Lĩnh vực
- build-system, tooling
Hướng nghiên cứu
Bắt đầu với read-wasm.js, read-wasm-browser.js, package.json và điểm vào SourceMapConsumer.initialize để hiểu fallback Node hiện tại và việc mapping trên trình duyệt. Xác minh rằng một Node consumer được đóng gói có thể cung cấp WASM thông qua initialize mà không cần thay đổi module, đồng thời fallback mappings.wasm hiện có vẫn hoạt động khi không có input nào được cung cấp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Support bundlers (esbuild, webpack) without requiring internal module swaps for WASM loading
Problem
When bundling source-map with esbuild (platform: node), the WASM loading breaks in production because:
read-wasm.jsusespath.join(__dirname, "mappings.wasm")— but after bundling,__dirnamepoints to the output directory, notnode_modules/source-map/lib/initialize()is a no-op in the Node version (read-wasm.js), so there's no way to provide the WASM from the consumer side without swapping toread-wasm-browser.jsvia a bundler resolve plugin- The
"browser"field inpackage.jsonmapsread-wasm.js→read-wasm-browser.js, but esbuild withplatform: node(correctly) ignores browser fields
This forces users to either:
- Copy
mappings.wasmto their output directory with the exact filename (fragile, undocumented contract) - Use a resolve plugin to swap
read-wasm.js→read-wasm-browser.jsand manually callinitialize()(depends on internal file paths)
Proposal
Make initialize() work regardless of platform — if the user provides WASM via initialize(), use it; otherwise fall back to the fs.readFile(__dirname) approach. This is essentially making the Node read-wasm.js behave like:
let initialized = null;
module.exports = function readWasm() {
if (initialized) return Promise.resolve(initialized);
// existing fs.readFile fallback
return new Promise((resolve, reject) => {
const wasmPath = path.join(__dirname, "mappings.wasm");
fs.readFile(wasmPath, null, (error, data) => {
if (error) reject(error);
else resolve(data.buffer);
});
});
};
module.exports.initialize = function (input) {
initialized = input;
};
This way bundler users can call SourceMapConsumer.initialize({"lib/mappings.wasm": wasmBuffer}) on Node without needing to swap modules.
Alternatives considered
- Exporting
mappings.wasmvia package.json"exports"so bundlers can resolve it cleanly - Shipping a pre-built JS fallback (like
source-map-jsdoes — no WASM at all)
Environment
- source-map 0.7.6
- esbuild 0.28.x, platform: node, format: esm
- Node.js 24.x
- Deploying to Docker (only
dist/is copied — nonode_modules)
- Ngôn ngữ chính
- JavaScript
- Star
- 3.7k
- Fork
- 374
- Merge trung bình
- 4 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của mozilla/source-map
-
Indexed column spans ignore section line offsets when clipping at the next sectionCó thể đã có người làm @NUAAwqy đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mozilla/source-map#539 ·
-
wasm-mappings fail to build with Rust 1.96+Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
mozilla/source-map#530 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
mozilla/source-map#524 · 6 bình luận ·
-
source map seems like not work, is there some hints from the perspective of source-map tool?Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
mozilla/source-map#516 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
mozilla/source-map#510 · 1 reaction ·
Tất cả issue của mozilla/source-map
Issue tương tự
-
Awaiting Maintainer Approval Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
processing/p5.js-web-editor#4364 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
JsCommunity/app-conf#22 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày