Skip to content

loader: add experimental text and bytes import#62300

Draft
efekrskl wants to merge 2 commits intonodejs:mainfrom
efekrskl:loader/experimental-raw-imports
Draft

loader: add experimental text and bytes import#62300
efekrskl wants to merge 2 commits intonodejs:mainfrom
efekrskl:loader/experimental-raw-imports

Conversation

@efekrskl
Copy link
Contributor

Closes #62082

Adds support for text and bytes import under --experimental-raw-imports flag.

Examples:

import text from './file.txt' with { type: 'text' };

import bytes from './file.txt' with { type: 'bytes' };

Import text is a Stage 3 TC39 proposal
Import bytes is a Stage 2.7 TC39 proposal

Deno supports this under --unstable-raw-imports (which I drew inspiration from).
Bun only supports text imports.

Not entirely sure what the current stance is on not-yet-landed proposals, but putting this up for discussion and feedback.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 17, 2026
@bakkot
Copy link
Contributor

bakkot commented Mar 18, 2026

Note that the import-bytes proposal requires producing Uint8Arrays backed by immutable ArrayBuffers, which are not yet supported in V8. I would be hesitant to ship this with mutable backing buffers, even flagged as experimental, lest people come to rely on that.

Text imports don't have the same problem.

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

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for importing text modules

3 participants