Chrome 155 Ships Text Modules: import a .txt File
On September 16, 2026 the Chrome for Developers team published the Chrome 155 beta release notes, and tucked among them is a small feature with an outsized effect on everyday code: Text Modules. Any text file can now be pulled in with a single import statement and arrives as a ready-to-use string.
import systemPrompt from "./agent-prompt.txt" with { type: "text" };
console.log(systemPrompt.length);The problem: text was always a second-class citizen
Every serious project has text living outside the code — a long SQL query, an HTML email template, a shader, a GraphQL schema, or the instruction text sent to an AI model. Every way of loading it carried a tax.
Option one: fetch. It works, but it is asynchronous, so every function that touches the text becomes async. Worse, its relative paths resolve against the document base URL rather than the location of the file that wrote the line. Move one file between folders and the path breaks, with nothing failing at build time.
Option two: a bundler-specific loader, such as a ?raw suffix. Practical and fast, but not part of the language. The code becomes married to one build tool, and the same file will not run unchanged in a browser or another runtime.
Option three: paste the text into a template literal. The technical problem vanishes and a different price appears: a bloated JavaScript file, no syntax highlighting, and no tool that understands the SQL inside it.
What changed
Text Modules moves this case into the language itself. The foundation is a TC39 proposal called Import Text, championed by Eemeli Aro, which its repository lists at Stage 3. The imported file becomes a Synthetic Module Record whose default export is a single string. Chrome 155 ships it on desktop, Android and WebView; Firefox has shipped it; Safari has an implementation in progress.
Three practical differences are worth noting.
The path resolves against the module. The specifier "./queries/top-sellers.sql" resolves relative to the file that wrote it, exactly like any other import. That alone removes an entire class of bugs that only appeared after a folder reorganization.
Loading happens during resolution. The text is fetched with the rest of the module graph before execution rather than after it. No loading state, no await, no window in which the variable is undefined.
Failure becomes explicit. If the file is gone, the graph breaks during loading instead of the error slipping silently through an unhandled fetch.
A real-world shape — a data layer that keeps its queries in .sql files:
import topSellers from "./queries/top-sellers.sql" with { type: "text" };
import { pool } from "./db.js";
export async function getTopSellers(storeId, limit = 10) {
const { rows } = await pool.query(topSellers, [storeId, limit]);
return rows;
}The query stays in a .sql file that the editor and any database linter understand, and the code reads it as a string with no extra build step.
Real-world caveats
No control over encoding. The proposal documents this limitation plainly: if a different encoding is needed, the route is importing the content as a Uint8Array and decoding it explicitly. Text Modules assume text, not binary data.
Permissions and CSP are part of the picture. The integration work includes Content Security Policy changes, and the load carries a new request destination at the network level. If the policy is tight, test before relying on it.
The text is now part of the module graph. That is both the benefit and the cost: editing the text file means a rebuild and a new hash. It is the wrong tool for content that changes after deployment — that remains fetch territory.
Support outside the browser is uneven. Check the target runtime and the build tool before deleting the fallback. Chrome 155 also adds the ability to retry a failed module load through import(), which is a useful safety net precisely here.
Takeaway
Text Modules will not reshape anyone's architecture, but they delete a layer of plumbing everyone was writing by hand. Text becomes a full citizen of the module graph: a path that can be trusted, deterministic loading, and a file that keeps its native format. This kind of consolidation — taking what proved useful in bundlers and moving it into the platform — is what lets code outlive the tools that built it.
Primary sources: the Chrome 155 beta release notes and the TC39 Import Text proposal. For context on how module resolution itself started treating specifiers as URLs, see Cloudflare Workers: Module Specifiers Are URLs Now.