π Search Terms
export defer, deferred re-exports, deferred re-exports, lazy barrel files
β
Viability Checklist
β Suggestion
Support the TC39 Deferred Re-exports proposal, which is now at Stage 2.7, including named and namespace re-exports:
export defer { a } from "./a.js";
export defer * as b from "./b.js";
Preserve the syntax in supported JavaScript output and declaration files, while retaining the types of exported bindings.
π Motivating Example
// a.ts
export function a(c: number, d: number): number {
return c + d;
}
// b.ts
export function b(c: number, d: number): number {
return c - d;
}
// c.ts
export defer { a } from "./a.js";
export defer { b } from "./b.js";
// d.ts
import { a } from "./c.js";
const b: number = a(1, 2);
Importing a does not require loading the unused module b.ts.
π» Use Cases
- What do you want to use this for?
Provide a shared entry point without loading unused modules
- What shortcomings exist with current approaches?
Ordinary static re-exports load unused dependencies in native ESM.
- What workarounds are you using in the meantime?
Alternatives are direct module imports or dynamic import().
π Search Terms
export defer, deferred re-exports, deferred re-exports, lazy barrel filesβ Viability Checklist
β Suggestion
Support the TC39 Deferred Re-exports proposal, which is now at Stage 2.7, including named and namespace re-exports:
Preserve the syntax in supported JavaScript output and declaration files, while retaining the types of exported bindings.
π Motivating Example
Importing
adoes not require loading the unused moduleb.ts.π» Use Cases
Provide a shared entry point without loading unused modules
Ordinary static re-exports load unused dependencies in native ESM.
Alternatives are direct module imports or dynamic
import().