> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript Namespace Export

A namespace export is an ECMAScript module (ESM) syntax that aggregates all named exports from a specified module and re-exports them as properties of a single Module Namespace Object under a new identifier.

```javascript theme={"dark"}
export * as identifierName from './module-path.js';
```

## Technical Mechanics

When the JavaScript engine encounters a namespace export, it performs the following operations:

1. **Resolution:** It resolves the target module specifier (`'./module-path.js'`).
2. **Aggregation:** It collects all exported bindings (variables, functions, classes) from the target module.
3. **Object Creation:** It constructs a Module Namespace Object (`[object Module]`).
4. **Re-exportation:** It exports this newly created namespace object from the current module using the specified `identifierName`.

## Live Bindings vs. Immutability

The generated Module Namespace Object is structurally immutable—it is sealed, and its properties cannot be added, removed, or reassigned. However, ESM utilizes **live bindings**. The properties on the namespace object are not static copies of values; they are direct references to the bindings in the source module. If the source module mutates an underlying exported variable, the value returned by the namespace object's property will dynamically update to reflect that change.

## Scope and Local Bindings

Crucially, a namespace export does **not** import the bindings into the current module's local scope.

This behavior distinguishes `export * as ...` from a two-step import-then-export process. The statement `import * as MathUtils from './math.js'; export { MathUtils };` creates a local `MathUtils` variable that can be accessed within the module. In contrast, `export * as MathUtils from './math.js';` performs the re-export directly without polluting the local scope. You cannot access the aggregated properties within the file performing the export.

## Execution Example

Given a source module with multiple named exports and a mutable variable:

```javascript theme={"dark"}
// source.js
export let counter = 0;
export function increment() { 
  counter++; 
}
```

The namespace export aggregates these into a single named export without creating a local binding:

```javascript theme={"dark"}
// aggregator.js
export * as CoreLogic from './source.js';

// ReferenceError: CoreLogic is not defined
// console.log(CoreLogic.counter); 
```

The consuming module imports the namespace object as a standard named import and observes the live bindings:

```javascript theme={"dark"}
// consumer.js
import { CoreLogic } from './aggregator.js';

console.log(CoreLogic.counter); // 0
CoreLogic.increment();
console.log(CoreLogic.counter); // 1 (Demonstrates live bindings)

// TypeError: Cannot assign to read only property 'counter'
// CoreLogic.counter = 5; 
```

## Default Export Behavior

If the target module contains a `default` export, the namespace export includes it as a property explicitly named `default` on the resulting Module Namespace Object.

```javascript theme={"dark"}
// ui-components.js
export const Button = () => {};
export default function App() {}

// aggregator.js
export * as UI from './ui-components.js';

// consumer.js
import { UI } from './aggregator.js';

console.log(UI.Button);  // [Function: Button]
console.log(UI.default); // [Function: App]
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor JavaScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
