# requirejs/text architecture

> Architecture diagram of the GitHub repository requirejs/text, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/requirejs/text
- Repository: https://github.com/requirejs/text

## Overview

This is a small AMD loader plugin that turns `text!` dependencies into resource contents. The main workflow parses the resource name, resolves its URL, chooses a loading path, optionally strips XML/HTML wrappers, and returns the result to the loader. It also supports optimizer inlining and environment-specific loading. The excerpts show the plugin’s dispatch and XHR logic; README statements document the other environments and optimizer behavior.

Main entry points: [`text.js`](https://github.com/requirejs/text/blob/master/text.js) (Plugin load)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_amd_consumer(("AMD consumer"))
node_plugin_load["Plugin load<br/>[text.js]"]
node_name_parser["Name parser<br/>[text.js]"]
node_url_resolver["URL resolver<br/>[text.js]"]
node_transport_choice["Transport choice<br/>[text.js]"]
node_xhr_transport["XHR transport<br/>[text.js]"]
node_other_environments["Node / Rhino<br/>[text.js]"]
node_script_resource["Cross-domain module"]
node_strip_content["Content stripping<br/>[text.js]"]
node_optimizer(("RequireJS optimizer"))
node_plugin_write["Optimizer output<br/>[text.js]"]

node_amd_consumer -->|"requests resource"| node_plugin_load
node_plugin_load -->|"parses name"| node_name_parser
node_plugin_load -->|"resolves URL"| node_url_resolver
node_plugin_load -->|"selects transport"| node_transport_choice
node_transport_choice -->|"uses XHR"| node_xhr_transport
node_transport_choice -->|"loads module"| node_script_resource
node_transport_choice -.->|"selects environment"| node_other_environments
node_plugin_load -->|"applies strip option"| node_strip_content
node_optimizer -->|"inlines resources"| node_plugin_write
node_plugin_write -.->|"provides built value"| node_amd_consumer

click node_plugin_load "https://github.com/requirejs/text/blob/master/text.js"
click node_name_parser "https://github.com/requirejs/text/blob/master/text.js"
click node_url_resolver "https://github.com/requirejs/text/blob/master/text.js"
click node_transport_choice "https://github.com/requirejs/text/blob/master/text.js"
click node_xhr_transport "https://github.com/requirejs/text/blob/master/text.js"
click node_other_environments "https://github.com/requirejs/text/blob/master/text.js"
click node_strip_content "https://github.com/requirejs/text/blob/master/text.js"
click node_plugin_write "https://github.com/requirejs/text/blob/master/text.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_amd_consumer,node_script_resource,node_optimizer toneIndigo
class node_plugin_load,node_name_parser,node_url_resolver,node_transport_choice,node_xhr_transport,node_other_environments,node_strip_content,node_plugin_write toneTeal
```

## Components

### Other components

- **AMD consumer**
- [Plugin load](https://github.com/requirejs/text/blob/master/text.js): `text.js`
- [Name parser](https://github.com/requirejs/text/blob/master/text.js): `text.js`
- [URL resolver](https://github.com/requirejs/text/blob/master/text.js): `text.js`
- [Transport choice](https://github.com/requirejs/text/blob/master/text.js): `text.js`
- [XHR transport](https://github.com/requirejs/text/blob/master/text.js): `text.js`
- [Node / Rhino](https://github.com/requirejs/text/blob/master/text.js): `text.js`
- **Cross-domain module**
- [Content stripping](https://github.com/requirejs/text/blob/master/text.js): `text.js`
- **RequireJS optimizer**
- [Optimizer output](https://github.com/requirejs/text/blob/master/text.js): `text.js`

## Connections

- AMD consumer → Plugin load: requests resource (evidence: `README.md`)
- Plugin load → Name parser: parses name (evidence: `text.js`)
- Plugin load → URL resolver: resolves URL (evidence: `text.js`)
- Plugin load → Transport choice: selects transport (evidence: `text.js`)
- Transport choice → XHR transport: uses XHR (evidence: `text.js`)
- Transport choice → Cross-domain module: loads module (evidence: `text.js`)
- Transport choice → Node / Rhino: selects environment (evidence: `README.md`)
- Plugin load → Content stripping: applies strip option (evidence: `README.md`)
- RequireJS optimizer → Optimizer output: inlines resources (evidence: `README.md`)
- Optimizer output → AMD consumer: provides built value (evidence: `text.js`)
