developit / developit/microbundle

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

Offen
#1,027 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
8.1k
Forks
358
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.