[BUG]: `events` is required but not declared in dependencies

Đang mở Phù hợp với người mới
#8,163 0 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.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
83/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, webpack
Lĩnh vực
build-system, frontend

Hướng nghiên cứu

Bắt đầu bằng cách đọc package.json và ba tệp được nêu trong báo cáo: src/lib/events.js, src/snapshot/toimage.js và src/snapshot/svgtoimg.js. Tái hiện lỗi bằng lệnh nghiêm ngặt pnpm install và webpack được cung cấp. Công việc được xem là hoàn tất khi gói khai báo dependency events cần thiết và bản build production thành công với các lần cài đặt nghiêm ngặt.

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

Mô tả

Description

src/lib/events.js, src/snapshot/toimage.js and src/snapshot/svgtoimg.js call require('events'), but events is not in the dependencies of package.json.

Since webpack 5 no longer polyfills Node.js core modules, the bundler resolves events to whatever version the package manager happens to hoist.
Today, it only resolves through a transitive dependency: regl-scatter2d → glslify → glslify-deps → events.
With strict installs (pnpm with hoist=false, Yarn PnP), the build fails.
With hoisted installs, another package's events can be picked up instead (e.g. [email protected]).

This happens with the latest release (4.2.0) and with 2.x.
events is the only Node.js core module still required under src/ (see also #6014 for older ones).

Steps to reproduce

package.json:

{
  "dependencies": { "plotly.js": "4.2.0" },
  "devDependencies": { "webpack": "5.106.0", "webpack-cli": "6.0.1" }
}

src/index.js:

import Plotly from "plotly.js/lib/core";
console.log(Plotly.version);
pnpm install --config.hoist=false
npx webpack --mode production
ERROR in ./node_modules/.pnpm/[email protected]/node_modules/plotly.js/src/lib/events.js 3:19-49
Module not found: Error: Can't resolve 'events' in '.../node_modules/.pnpm/[email protected]/node_modules/plotly.js/src/lib'
Ngôn ngữ chính
JavaScript
Star
18.4k
Fork
2.1k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
9

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 plotly/plotly.js

Tất cả issue của plotly/plotly.js

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.