Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Question] Sub-exports depending on main export bundle the entire main-export.

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

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
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, rollup, typescript
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

Bắt đầu với các ví dụ index.ts, main.ts và a.ts, đồng thời kiểm tra cách microbundle tạo ra các đầu ra dist/a.* cho từng định dạng. Trước tiên, hãy kiểm tra cấu hình sub-export trong package.json và việc xử lý external của Rollup. Hoàn thành khi các bundle ./a không inline main.ts mà vẫn giữ import được yêu cầu và cách sử dụng UMD.

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

Mô tả

I have a project where I have a main-export and multiple other exports. The other exports are extensions that depend on the main-export, but I don't want them to be in the main-export to keep it as small as possible.

Users should be able to do:

import {Thing} from 'package';

// optional addition
import {OtherThing} from 'package/a';

(or similarly using multiple script-tags with the umd-builds)

As for the source-files, it's roughly like this:

// index.ts
export * from './main';

// main.ts
export class Thing {}

// a.ts
import {Thing} from './main';

export class OtherThing extends Thing {}

And the package.json contains these sub-exports:

"exports": {
    ".": {
      "import": "./dist/index.modern.js",
      "require": "./dist/index.js",
      "umd": "./dist/index.umd.js",
      "browser": "./dist/index.module.js"
    },
    "./a": {
      "import": "./dist/a.modern.js",
      "require": "./dist/a.js",
      "umd": "./dist/a.umd.js",
      "browser": "./dist/a.module.js"
    },
  }

With this, the output-files for './a' (all formats) have the entire definition of './main.ts' inlined.

So my question is, is there a way to configure microbundle to treat those other files as externals?

Ngôn ngữ chính
JavaScript
Star
8.1k
Fork
358
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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 developit/microbundle

Tất cả issue của developit/microbundle

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.