developit / developit/microbundle

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

未关闭
#1,027 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
8.1k
派生
358
PR 合并指标
30 天内没有已合并 PR

描述

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:

```javascript
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:

```typescript
// 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?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。