Skip to content

javascript: ES re-exports other than export * yield nothing — export { a as b } from, export { default } from, export * as ns from #483

Closed

Description

@swapnilpaliwal-sd

Part of #456. Parser and engine halves; the engine cannot work around the first without a join the parser does not provide.

Symptom

Only export * from './x.js' survives a barrel. Every other ES re-export form yields nothing on the importing side:

// barrel.js
export * from './base.js';                                   // works
export { util as utilAlias, Base as BaseAlias } from './base.js';   // MISSED
export { default } from './base.js';                         // MISSED
export { default as baseDefault } from './base.js';          // MISSED
export * as ns from './base.js';                             // MISSED  (barrel.ns.util())
// chain.js
export * from './barrel.js';
export { ns as nested } from './barrel.js';                  // MISSED

import { utilAlias, BaseAlias, ns, baseDefault } from './barrel.js' and import * as barrel with barrel.utilAlias(), new barrel.BaseAlias().id(), barrel.ns.util(), barrel.default(): 18 of 45 compiler-decided sites MISSED on a synthetic program whose only feature is these forms; Sub.make() on a class reached through an alias is SYNTHESIZED_MISSED.

Mechanism

Parser. For export * from, the parser mints a NAMESPACE js_import row and sets reExportImportLinkHash on the EXPORT_ALL row — that is the join module-graph.dl uses (export_reexport(_, _, imp, x), import_module(imp, src)). For export { a as b } from './x' it emits exportForm = EXPORT_DECLARATION, isReExport = true, reExportSpecifier = './x', localName = a, and no import row and an empty reExportImportLinkHash. The specifier is a string the engine cannot resolve (module resolution — extensions, index.js, package.json#main — lives in the parser, and js_import.resolvedFilePath is the only resolved path in the IR).

export * as ns from './x' is emitted as exportForm = EXPORT_ALL with exportedName = "ns" (and an import row). The engine's EXPORT_ALL rule spreads the source module's surface onto the barrel under every name — correct for *, wrong for ns, which should be one export whose value is the source module itself.

Engine. module_export_value(mod, en, k, i) :- export_decl(_, en, ln, form, …), form != "EXPORT_ALL", export_reexport(_, _, imp, x), import_module(imp, src), module_export_value(src, ln, k, i) is the right rule and is starved by the missing link. export { default as X } from additionally needs ln = "default" to read the source's default export, which the same rule does once linked.

Fix

  1. Parser (js-declaration-extractor / module-edge minting): every isReExport export row gets an import row for its specifier and reExportImportLinkHash set, exactly as EXPORT_ALL does today.
  2. Parser: export * as ns from should be its own form (or EXPORT_ALL with exportedName != "*" documented as the namespace form) so the engine can distinguish it.
  3. Engine module-graph.dl: the EXPORT_ALL spread rule restricted to exportedName = "*"; a new rule module_export_value(mod, n, "module", src) :- export_decl(_, n, _, "EXPORT_ALL", …), n != "*", export_reexport(…), import_module(imp, src).

Verification

Synthetic ESM program (barrel → chain → consumer); the regression suite's case 02 covers export * only.

Activity

  1. added
    bug
    engine
    javascript
    parser-blocked
    on Sep 14, 2026
  2. swapnilpaliwal-sd commented on Sep 14, 2026

    @swapnilpaliwal-sd
    ContributorAuthor

    Parser half landed on main in #494 (192f345): every ES re-export now mints its import row and sets reExportImportLinkHash — export { a as b } from, export { default } from, export { default as y } from — with bindingForm = NO_LOCAL_BINDING and importedName the source-side name. export * as ns from stays EXPORT_ALL with exportedName = ns, which is the documented spelling the engine can distinguish from the bare spread by the name.

    Measured on the barrel from this issue: 7 export rows, the 6 re-exports each import-linked, the local export not; 6 import rows to ./base.js, all RESOLVED_PROJECT.

    Engine half still open (the javascript-engine branch's module-graph.dl): restrict the EXPORT_ALL spread rule to exportedName = "*", and add the namespace rule module_export_value(mod, n, "module", src) for n != "*". The general re-export rule the issue writes out — export_reexport(_, _, imp, x), import_module(imp, src), module_export_value(src, ln, k, i) for form != "EXPORT_ALL" — now has the join it needed.

    Leaving open, relabelled engine only: the parser-blocked half is done.

  3. removed
    parser-blocked
    on Sep 14, 2026
  4. swapnilpaliwal-sd commented on Sep 14, 2026

    @swapnilpaliwal-sd
    ContributorAuthor

    Engine half landed on javascript-engine-reshape (commit 8aaf1f4): export * as ns from './x.js' is a module value on the surface (export_all_is_spread tells the two export * forms apart), and export * from chains through a barrel resolve — probe e-esm sites barrel.ns.util(), new barrel.ns.Base().id(), chain.ns.util(), nested.util() are EXACT.

    What stays open is the parser half: export { a as b } from, export { default } from, export { default as x } from mint no import row and no reExportImportLinkHash; the specifier is a string the engine has no value for. Probe e-esm: exact 0.689 / recall 0.778, all ten remaining misses are these three forms (case 14-esm-reexports lists them as known-missing). Relabelled parser-blocked; the engine rule is one line once the import row exists (the same import_value path export * already takes).

  5. added
    parser-blocked
    and removed
    parser-blocked
    on Sep 14, 2026
  6. swapnilpaliwal-sd commented on Sep 14, 2026

    @swapnilpaliwal-sd
    ContributorAuthor

    Closed by the parser half in #494 plus the engine on javascript-engine-reshape (commit 9a09182): every re-export's import row is read through the same import_value path export * already took — no new rule was needed for export { a as b } from / export { default } from / export { default as x } from. Case 14-esm-reexports: all ten sites that were known-missing are EXACT (the known-missing file is gone); suite 19/19; both corpora unchanged or better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugenginejavascript

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions